-
Notifications
You must be signed in to change notification settings - Fork 38.5k
PathMatchingResourcePatternResolver fails to work under Tomcat 8.0.41 with unpackWARs=false [SPR-15332] #19895
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
Comments
Juergen Hoeller commented Andy Wilkinson, Stéphane Nicoll, are you aware of this on Boot's end already? It looks like we'll have to specifically parse the new "war:" protocol there... |
Andy Wilkinson commented Yes: spring-projects/spring-boot#7949. I'm not sure why I didn't connect the dots and consider that a change in the Framework may be appropriate here. Sorry. To make matters better or worse depending on your perspective, 8.5.12 is going to make the separator configurable. See the aforelinked Boot issue for details. |
Juergen Hoeller commented At the very least, we can detect "war" as a jar-like URL protocol in I'm reluctant to bake any specific separator syntax into our fallback algorithm there, given that it's going to be configurable. I rather assume that our |
Thomas Meyer commented Hi, I think the fix in commit 899f235 is incomplete, because it jar: URLs have separator "!/" and war: URLs have separator "*/". |
Thomas Meyer commented Untested proposed fix: thomasmey@1651ddd |
Juergen Hoeller commented This is intentional, actually: The "war" URL separator is configurable as of Tomcat 8.5.12, so we cannot make reliable assumptions about it. Instead, the only code path that we're currently trying to make work is the Of course, if this turns out to be insufficient, we'll revisit it in time for the 4.3.8 release still. |
Thomas Meyer commented Mhh, okay I see. Relevant commit is apache/tomcat80@9d0b619 - but as far as I see */ would still be the default, so for every web app using spring this property must get set in setenv.sh to work correctly?! |
Juergen Hoeller commented A key motivation for making it configurable is that the default separator isn't a good fit with Spring apps due to "*" being interpreted as a wildcard in quite a few code paths... So they intend to change the separator for the embedded Tomcat in Spring Boot by default, bending the expectation of a default on our end. Triggering the In the worst case, i.e. if there is no way to get a |
Andy Wilkinson commented I'm hopeful that, in light of the change made here, we won't need to customise the separator in Boot. That should be the case if opening a connection to the |
Juergen Hoeller commented Andy Wilkinson, alright, that's good to know! This change is currently just in master. I have yet to backport it to 4.3.x later this week, ideally once it's known to work. So it'd be great if you could try it in Boot 2.0 first... |
Andy Wilkinson commented I've built 164204c locally. Unfortunately, it fails:
The |
Andy Wilkinson commented It works if I change the separator to |
Juergen Hoeller commented OK, at least we don't have to bake any custom Boot-specific separator syntax into our core resolver... since the So why specifically doesn't it work with the "*/" separator then... Where are we mis-interpreting it as a wildcard? I assume Boot's URL handler receives a truncated jar URL there, or is it possibly over-insisting on a "!/" separator at that level? |
Andy Wilkinson commented The misinterpretation happens here: Line 290 in 164204c
|
Juergen Hoeller commented Hmm, since we're already restricting the pattern check to the URL path after a prefix, we could als add some rule for the pattern check to ignore a separator. What does the |
Andy Wilkinson commented That's in my comment above:
|
Juergen Hoeller commented Ah yes, sorry for not seeing that right away :-) |
Juergen Hoeller commented If we can't identify a more generic pattern to apply here, we could at least do this (even if it's quite specific) in
|
Juergen Hoeller commented I've rolled such a specific check into master now. We may revisit this later on... but since we got special checks for other platform URL formats already, I don't really mind handling this specifically. |
Andy Wilkinson commented Thanks, Juergen. I've built 71852a9 locally and can confirm that it fixes the problem without any customisation of the separator. |
Alexey Veklov commented Hi It looks like the issue has not been fully fixed, or it manifests itself in several ways. Here is how it manifests itself in my case (Spring 4.3.8.RELEASE):
The following patch (between comments PATCH START and PATCH END) fixes the issue:
|
Juergen Hoeller commented Good catch. I'm rolling that change into 5.0 RC1 (and 4.3.9) as part of the related ticket #20045. |
Alexey Veklov commented Hi It looks like ResourceUtils.extractArchiveURL also has an issue (Spring 4.3.8.RELEASE). See comments in below snippet:
|
Juergen Hoeller commented Alexey Veklov, could you please create a new JIRA issue for your scenario? We'll target a revision for 4.3.9 then. |
Thomas Meyer opened SPR-15332 and commented
Because of Tomcat commit apache/tomcat80@7e767cc#diff-a72fb99b0729353084d2c437f749e718 ResourceUtils.isJarURL will return false https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java#L473 and then Spring tries to access the non-existing file from filesystem and will issue the warning "Cannot search for matching files underneath because it does not correspond to a directory in the file system" https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java#L665
I did see this bug with Spring 4.x but seems still to exists on master branch.
Issue Links:
Referenced from: commits 57c8c75, 012c56a, 899f235
1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: