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

Files in META-INF are not found when deploying a Gradle-built executable war to a servlet container #30026

Closed
gurpreetsingh85 opened this issue Mar 2, 2022 · 4 comments
Assignees
Labels
type: regression A regression from a previous release
Milestone

Comments

@gurpreetsingh85
Copy link

Java Version - 11
Spring Boot Version - 2.6.4
Tomcat Version - 9.0.59

Starting with Spring Boot version 2.6.4 environment prepared method is not getting called when spring boot application is deployed as a war to external tomcat server.

Attached is the project to simulate behavior along with snapshots showing difference between 2.6.3 and 2.6.4

Change version of Spring Boot in build.gradle file to reproduce.

demo.zip

2 6 3

2 6 4

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 2, 2022
@wilkinsona wilkinsona self-assigned this Mar 2, 2022
@wilkinsona
Copy link
Member

Thanks for the report. Unfortunately, the sample that you have provided does not reproduce the behaviour that you have described. With 2.6.4, I see your EnvironmentPostProcessor being called:

02-Mar-2022 09:53:15.651 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/Users/awilkinson/dev/temp/gh-30026/apache-tomcat-9.0.59/webapps/ROOT.war]
02-Mar-2022 09:53:16.962 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
********************
ENVIRONMENT_PREPARED
********************

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.4)

2022-03-02 09:53:17.632  INFO 57611 --- [           main] com.example.demo.ServletInitializer      : Starting ServletInitializer using Java 11.0.10 on wilkinsona-a01.vmware.com with PID 57611 (/Users/awilkinson/dev/temp/gh-30026/apache-tomcat-9.0.59/webapps/ROOT/WEB-INF/classes started by awilkinson in /Users/awilkinson/dev/temp/gh-30026)
2022-03-02 09:53:17.635  INFO 57611 --- [           main] com.example.demo.ServletInitializer      : No active profile set, falling back to 1 default profile: "default"
2022-03-02 09:53:18.383  INFO 57611 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 690 ms
2022-03-02 09:53:18.889  INFO 57611 --- [           main] com.example.demo.ServletInitializer      : Started ServletInitializer in 1.73 seconds (JVM running for 4.378)
02-Mar-2022 09:53:18.914 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/Users/awilkinson/dev/temp/gh-30026/apache-tomcat-9.0.59/webapps/ROOT.war] has finished in [3,262] ms
02-Mar-2022 09:53:18.916 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
02-Mar-2022 09:53:18.924 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [3335] milliseconds

Can you please describe how to use your sample to reproduce the problem?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Mar 2, 2022
@gurpreetsingh85
Copy link
Author

@wilkinsona
Thank you for quick response.

I am attaching another sample project. This time i have disabled traditional war task.
Running ./gradlew clean build should only build boot war and deploying it to external tomcat should reproduce this issue.

demo.zip

Screen Shot 2022-03-02 at 5 58 31 AM

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 2, 2022
@wilkinsona
Copy link
Member

Thanks. I've reproduced the problem now. It's a regression caused by the changes for #28562. The spring.factories file is being packaged in META-INF/spring.factories rather than in WEB-INF/classes/META-INF/spring.factories which means it can't be found when deployed as a war file.

@wilkinsona wilkinsona added this to the 2.5.11 milestone Mar 2, 2022
@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Mar 2, 2022
@wilkinsona wilkinsona changed the title Spring Boot 2.6.4 -> SpringApplicationRunListener.environmentPrepared event is not getting called An application's spring.factories file is not found when deploying a Gradle-built executable war to a servlet container Mar 2, 2022
@wilkinsona
Copy link
Member

The Maven repackaging only applies its special handling of META-INF for a RepackagingLayout. org.springframework.boot.loader.tools.Layouts.War is not a RepackagingLayout so war files are not affected. The changes for #28562 need to be modified so that they only apply to jars.

@wilkinsona wilkinsona changed the title An application's spring.factories file is not found when deploying a Gradle-built executable war to a servlet container Files in META-INF are not found when deploying a Gradle-built executable war to a servlet container Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants