嵌入的tomcat 7无法正确关闭 ClassNotFoundException ContainerBase$StopChild
Posted
技术标签:
【中文标题】嵌入的tomcat 7无法正确关闭 ClassNotFoundException ContainerBase$StopChild【英文标题】:tomcat 7 embedded doesn't shutdown correctly ClassNotFoundException ContainerBase$StopChild 【发布时间】:2014-01-10 18:21:25 【问题描述】:我正在尝试使用具有此配置的 Tomcat7 嵌入式插件进行工作集成测试:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>29360</port>
<systemProperties>
<logback.configurationFile>$project.build.testOutputDirectory/logback-test.xml</logback.configurationFile>
<psw.config>$project.build.testOutputDirectory</psw.config>
<spring.profiles.active>test-e2e</spring.profiles.active>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>$slf4j.version</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>$logback.version</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>run-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-war-only</goal>
</goals>
<configuration>
<fork>true</fork>
</configuration>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
但是当关机发生时,我一直有这个错误: 引起:java.lang.ClassNotFoundException: org.apache.catalina.core.ContainerBase$StopChild
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:49.618s
[INFO] Finished at: Sun Dec 22 07:58:06 CET 2013
[INFO] Final Memory: 163M/259M
[INFO] ------------------------------------------------------------------------
ERROR: IllegalAccessException for stop method in class org.apache.tomcat.maven.plugin.tomcat7.run.ExtendedTomcat
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tomcat.maven.common.run.EmbeddedRegistry.shutdownAll(EmbeddedRegistry.java:110)
at org.apache.tomcat.maven.common.run.EmbeddedRegistry$1.run(EmbeddedRegistry.java:69)
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardServer[-1]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:351)
... 6 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardService[Tomcat]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:753)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to stop component [StandardEngine[Tomcat]]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:236)
at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 9 more
Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/core/ContainerBase$StopChild
at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1173)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.core.ContainerBase$StopChild
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
... 13 more
Process finished with exit code 0
有什么提示可以解决这个问题吗?
【问题讨论】:
我遇到了同样的问题。使用“mvn verify”运行集成测试后,服务器无法停止,但奇怪的是,这只发生在集成测试失败时。如果它们运行正确,服务器会尝试正确关闭,并且我收到此警告“与线程池 [http-bio-8087] 关联的执行程序尚未完全关闭。一些应用程序线程可能仍在运行。'。 【参考方案1】:如果您运行 mvn integration-test,它将不会运行 post-integration-test 阶段,这可能会导致此错误。请改用 mvn verify。
【讨论】:
我遇到了类似的问题,“mvn verify”对我有用 :)以上是关于嵌入的tomcat 7无法正确关闭 ClassNotFoundException ContainerBase$StopChild的主要内容,如果未能解决你的问题,请参考以下文章
Spring boot 2 embed tomcat 9.0.26 无法加载jks文件流关闭
Spring Boot 2.1 嵌入式 Tomcat - 密钥库密码不正确