问题
I have created maven multi-module project, one child is spring boot-2.1.8.RELEASE & another Angular 8. Created a war file from both spring boot and angular. Created 'manifest.yml' file in parent project, pushed war file to pivotal cloud foundry. Getting ClassNotFoundException org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
.
Below are the logs:
2019-11-13T15:32:54.968-05:00 [APP/PROC/WEB/1] [OUT] at java.lang.Thread.run(Thread.java:745)
2019-11-13T15:32:54.968-05:00 [APP/PROC/WEB/1] [OUT] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
2019-11-13T15:32:54.968-05:00 [APP/PROC/WEB/1] [OUT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
2019-11-13T15:32:54.968-05:00 [APP/PROC/WEB/1] [OUT] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2019-11-13T15:32:54.970-05:00 [APP/PROC/WEB/1] [OUT] [CONTAINER] org.apache.catalina.startup.HostConfig INFO Deployment of web application directory /home/vcap/app/.java-buildpack/tomcat/webapps/ROOT has finished in 4,941 ms
2019-11-13T15:32:54.971-05:00 [APP/PROC/WEB/1] [OUT] [CONTAINER] pplicationStartupFailureDetectingLifecycleListener SEVERE Error: Application '' failed (state = FAILED): see Tomcat's logs for details. Halting Tomcat.
2019-11-13T15:32:55.064-05:00 [APP/PROC/WEB/1] [OUT] Exit status 148
2019-11-13T15:32:55.071-05:00 [CELL/SSHD/1] [OUT] Exit status 0
2019-11-13T15:32:55.402-05:00 [CELL/2] [OUT] Cell dfb8ab52-b8db-4e3a-8d5c-870bdbd271be destroying container for instance 4623a137-41c1-4d58-692d-256b
2019-11-13T15:32:55.402-05:00 [CELL/2] [OUT] Cell dfb8ab52-b8db-4e3a-8d5c-870bdbd271be stopping instance 4623a137-41c1-4d58-692d-256b
2019-11-13T15:32:55.510-05:00 [CELL/4] [OUT] Cell 7f72ec19-9a0f-4f5d-96f9-2278880c8d0d destroying container for instance 4c17e338-c212-4edc-764f-339a
2019-11-13T15:32:55.510-05:00 [CELL/4] [OUT] Cell 7f72ec19-9a0f-4f5d-96f9-2278880c8d0d stopping instance 4c17e338-c212-4edc-764f-339a
2019-11-13T15:32:55.537-05:00 [API/3] [OUT] Process has crashed with type: "web"
2019-11-13T15:32:55.551-05:00 [API/3] [OUT] App instance exited with guid b31cfb32-bc36-4b85-8719-b044984acecb payload: {"instance"=>"4c17e338-c212-4edc-764f-339a", "index"=>4, "cell_id"=>"7f72ec19-9a0f-4f5d-96f9-2278880c8d0d", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 148", "crash_count"=>3, "crash_timestamp"=>1573677175500308651, "version"=>"9ef7a2f5-12e7-43ee-b0a9-76e18b96db27"}
2019-11-13T15:32:55.820-05:00 [CELL/2] [OUT] Cell dfb8ab52-b8db-4e3a-8d5c-870bdbd271be successfully destroyed container for instance 4623a137-41c1-4d58-692d-256b
2019-11-13T15:32:55.912-05:00 [CELL/4] [OUT] Cell 7f72ec19-9a0f-4f5d-96f9-2278880c8d0d successfully destroyed container for instance 4c17e338-c212-4edc-764f-339a
2019-11-13T15:32:56.013-05:00 [API/0] [OUT] Process has crashed with type: "web"
2019-11-13T15:32:56.024-05:00 [API/0] [OUT] App instance exited with guid b31cfb32-bc36-4b85-8719-b044984acecb payload: {"instance"=>"4623a137-41c1-4d58-692d-256b", "index"=>2, "cell_id"=>"dfb8ab52-b8db-4e3a-8d5c-870bdbd271be", "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 148", "crash_count"=>3, "crash_timestamp"=>1573677175928158322, "version"=>"9ef7a2f5-12e7-43ee-b0a9-76e18b96db27"}
2019-11-13T15:32:56.280-05:00 [APP/PROC/WEB/0] [OUT] . ____ _ __ _ _
2019-11-13T15:32:56.281-05:00 [APP/PROC/WEB/0] [OUT] =========|_|==============|___/=/_/_/_/
2019-11-13T15:32:56.281-05:00 [APP/PROC/WEB/0] [OUT] ' |____| .__|_| |_|_| |_\__, | / / / /
2019-11-13T15:32:56.281-05:00 [APP/PROC/WEB/0] [OUT] \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2019-11-13T15:32:56.281-05:00 [APP/PROC/WEB/0] [OUT] ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2019-11-13T15:32:56.281-05:00 [APP/PROC/WEB/0] [OUT] /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2019-11-13T15:32:56.284-05:00 [APP/PROC/WEB/0] [OUT] :: Spring Boot :: (v2.1.8.RELEASE)
2019-11-13T15:32:56.502-05:00 [APP/PROC/WEB/0] [OUT] 2019-11-13 20:32:56.496 INFO 21 --- [ost-startStop-1] pertySourceApplicationContextInitializer : Adding 'cloud' PropertySource to ApplicationContext
2019-11-13T15:32:56.669-05:00 [APP/PROC/WEB/0] [OUT] 2019-11-13 20:32:56.668 INFO 21 --- [ost-startStop-1] nfigurationApplicationContextInitializer : Adding cloud service auto-reconfiguration to ApplicationContext
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] ... 27 common frames omitted
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) ~[catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) ~[catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1834) [catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1092) [catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) [catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) [catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) [catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5292) [catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171) [spring-web-5.1.9.RELEASE.jar:5.1.9.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:623) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.cloudfoundry.container.customizer.AllowLinkingApplicationContextInitializer.initialize(AllowLinkingApplicationContextInitializer.java:26) ~[container_customizer-1.0.0_RELEASE.jar:1.0.0.RELEASE]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1301) ~[catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:858) ~[catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2541) ~[catalina.jar:8.0.36]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_101]
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizer
2019-11-13T15:32:56.712-05:00 [APP/PROC/WEB/0] [OUT] 2019-11-13 20:32:56.710 ERROR 21 --- [ost-startStop-1] o.s.boot.SpringApplication : Application run failed
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] ... 27 more
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] ... 10 more
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5292)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:367)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:623)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.cloudfoundry.container.customizer.AllowLinkingApplicationContextInitializer.initialize(AllowLinkingApplicationContextInitializer.java:26)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1301)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:858)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2541)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] at java.lang.ClassLoader.defineClass1(Native Method)
2019-11-13T15:32:56.714-05:00 [APP/PROC/WEB/0] [OUT] Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizer
Please check and let me know any configuration file required to debug. Java build pack v3.9 is configured in company's cloud foundry, this build pack has tomcat v8. I am not sure where this class is getting loaded. Spring boot 2 does not have this file. Does anyone had a similar issue? Updating maven dependencies:
Parent pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.org</groupId>
<artifactId>Dashboard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Dashboard</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
<module>Frontend</module>
<module>Backend</module>
</modules>
</project>
backend.pom.xml
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.org</groupId>
<artifactId>Dashboard</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Backend</artifactId>
<packaging>war</packaging>
<name>Backend</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<!--This dependency includes JPA, JPA Implementation. default JPA implementaiton
is hibernate. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId><!-- managed version is 8.0.17
with spring boot 2.1.8 RELEASE -->
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.org</groupId>
<artifactId>Frontend</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.Application</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>Dashboard</warName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.parent.basedir}/Backend/src/main/resources/static</outputDirectory>
<resources>
<resource>
<directory>${project.parent.basedir}/Frontend/src/main/web/dist/Dashboard/</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Frontend pom.xml
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.org</groupId>
<artifactId>Dashboard</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>Frontend</artifactId>
<name>Frontend</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<nodeVersion>v10.16.3</nodeVersion>
<npmVersion>6.9.0</npmVersion>
<workingDirectory>src/main/web/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I did more research and found out, EmbeddedServletContainerCustomizer does not exist in spring-boot2, it exists in spring boot-1.5 and prior versions.Analyzing more on java-buildpack-container customizer, when it invokes container customizer to customize tomcat container, suppose if there are any server properties configured in application.properties, then?
来源:https://stackoverflow.com/questions/58887562/spring-boot-war-file-deployed-in-cloud-foundry-throwing-class-not-found-exceptio