Skip to content

Last modified check of Resource created from Tomcat war:file: URL fails with FileNotFoundException [SPR-15485] #20045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Apr 26, 2017 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 26, 2017

Andy Wilkinson opened SPR-15485 and commented

This is, I believe, a regression due to the changes made in this commit. A side-effect of those changes is that AbstractFileResolvingResource now proceeds with file system resolution where as, previously, it would have use the last modified header on the URL connection.

The file system resolution fails with an exception like this:

java.io.FileNotFoundException: Jar URL cannot be resolved to absolute file path because it does not reside in the file system: war:file:/home/vbao/service/vbao-web.war*/js/bootstrap.min.js
	at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:215)
	at org.springframework.core.io.AbstractFileResolvingResource.getFileForLastModifiedCheck(AbstractFileResolvingResource.java:67)
	at org.springframework.core.io.AbstractResource.lastModified(AbstractResource.java:153)
	at org.springframework.core.io.AbstractFileResolvingResource.lastModified(AbstractFileResolvingResource.java:169)
	at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:345)
	…

Affects: 4.3.8

Reference URL: spring-projects/spring-boot#8986

Issue Links:

Referenced from: commits d43dfc7, d298561, 3daf626

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I'm surprised that the ResourceUtils.extractArchiveURL doesn't do the job here: It should return file:/home/vbao/service/vbao-web.war in such a scenario, which is then what getFileForLastModifiedCheck enters ResourceUtils.getFile with...

I guess we should make that check more defensiveness, but nevertheless, it'd be great to find out why specifically the archive check doesn't work.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've added a defensive fallback for FileNotFoundException, going with the URL connection check instead. Nevertheless, the archive extraction check should work fine as well here...

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

As per https://jira.spring.io/browse/SPR-15332?focusedCommentId=151543&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-151543, we also have a specific check for Tomcat war URLs in our jar file extraction code now (for 5.0 RC1 and 4.3.9, along with the other changes in this ticket).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants