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

Configure embedded containers to load static resources from fat jar's BOOT-INF/classes/META-INF/resources #8324

Closed
mcirikovic opened this issue Feb 17, 2017 · 7 comments
Assignees
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@mcirikovic
Copy link

Might be related to: #7595 (or at least to a comment in this issue)

Starting with 1.4.3, our JSF application isn't processing JSF pages anymore.

  • The application still starts and seems to work, but when we call a JSF page, it returns an error:
    /index.xhtml Not Found in ExternalContext as a Resource
  • After reading JarLauncher configures the class path such that resources are found twice #7595, i switched back to 1.5.1, but used the spring-boot-maven-plugin from version 1.4.2. Now the application starts with version 1.5.1 but JSF is still working.

I've appended a small example application. After started, call http://localhost:8085/index.xhtml.

  • If Spring Boot <=1.4.2 is used, the page shows something like "--|test value|--".
  • If Spring Boot >= 1.4.3 is used, an error page is displayed
  • If Spring Boot >= 1.4.3 with spring-boot-maven-plugin:1.4.2 is used, no error occurs and the expected "--|test value|--" is shown

BugTest.zip

BTW: If you start the application in Eclipse with the Spring Plugin, the result depends on your eclipse environment (for some developers it works, for some not - guess it depends, which loader is used by eclipse),

@wilkinsona
Copy link
Member

wilkinsona commented Feb 18, 2017

The change that has stopped this from working is intentional as it aligns Spring Boot more closely with the Servlet spec.

The spec states that resources in META-INF/resources should be loaded from jars packaged in WEB-INF/lib but should not be loaded from META-INF/resources within the main archive. In 1.4.2 and earlier (and only with Tomcat (see #8299)) we loaded resources from META-INF/resources within the main archive (actually from BOOT-INF/classes/META-INF/resources). In 1.4.3 and later we now only load resources from META-INF/resources of a jar packaged in BOOT-INF/lib.

The one significant difference between a jar and a war file is that a war project can use src/main/webapp to package resources in the root of the archive from where they will be accessible. This isn't an option with a jar. We can consider officially supporting BOOT-INF/classes/META-INF/resources as an extension to what the Servlet spec suggests, but I'm yet to convince myself that it's a good idea.

In the meantime, you have two options here:

  • Package your application as a war file and use src/main/webapp/ for your resources rather than src/main/resources/META-INF/resources/. You can still launch it using java -jar.
  • Continue packaging your application as a jar file, but move your resources into a separate module and make your app depend on the module such that its jar is packaged in BOOT-INF/lib

I'm going to close this in favour of #8299 which will make resource handling consistent across all three containers. We'll consider supporting BOOT-INF/classes/META-INF/resources as part of that.

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 18, 2017
@wilkinsona
Copy link
Member

On second thoughts, this would be better handled as a separate issue rather than rolling it into #8299

@wilkinsona wilkinsona reopened this Feb 19, 2017
@wilkinsona wilkinsona changed the title JSF applications not working starting with 1.4.3 spring-boot-maven-plugin (JarLoader) Configure embedded containers to load static resources from fat jar's BOOT-INF/classes/META-INF/resources Feb 19, 2017
@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review type: enhancement A general enhancement and removed status: duplicate A duplicate of another issue labels Feb 19, 2017
@wilkinsona wilkinsona added this to the 2.0.0.M2 milestone Mar 31, 2017
@wilkinsona wilkinsona added priority: normal and removed for: team-attention An issue we'd like other members of the team to review labels Mar 31, 2017
@wilkinsona wilkinsona self-assigned this Jun 15, 2017
@wilkinsona wilkinsona modified the milestones: 2.0.0.M3, 2.0.0.M2 Jun 15, 2017
@GyllingSW
Copy link

This is also the case for JSP pages. My Kerberos bases SSO solution stops working, when the Spring Boot Maven Plugin is later than 1.4.2.RELEASE

@wilkinsona
Copy link
Member

@GyllingSW JSPs are only supported when you package your application as a war file

@GyllingSW
Copy link

@wilkinsona - I know JSP has limitations, but non the less it works with the maven plugin <= the 1.4.2.RELEASE version.
I use the approach shown here:
https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp

@wilkinsona
Copy link
Member

@GyllingSW That sample is fine. It is building a war file. If you're doing that then there's no problem

@wilkinsona wilkinsona modified the milestones: 2.0.0.M6, 2.0.0.RC1 Oct 30, 2017
@philwebb philwebb removed this from the 2.0.0.M7 milestone Nov 8, 2017
@wilkinsona
Copy link
Member

I'm going to close this. There's been relatively little demand for it yet implementing it would add complexity to achieve something that can already been done using one of the two options that I described in my comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants