Skip to content
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

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

Closed
spring-issuemaster opened this Issue Apr 26, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster 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:

  • #19895 PathMatchingResourcePatternResolver fails to work under Tomcat 8.0.41 with unpackWARs=false
  • #21853 HTTP 404 for static resources with last modified = 0L (breaks Docker images build with Jib)

Referenced from: commits d43dfc7, d298561, 3daf626

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Apr 26, 2017

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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Apr 26, 2017

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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented May 3, 2017

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
You can’t perform that action at this time.