我正在尝试将Spring Boot应用程序部署到EAP 7服务器。该应用程序可以使用Spring Boot的嵌入式tomcat servlet作为独立应用程序正常运行,但是当我尝试将其作为WAR部署到EAP 7时,出现以下异常:
14:55:11,156 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 70) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host."projectName": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."projectName": java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager
at org.apache.tomcat.websocket.WsWebSocketContainer.<clinit>(WsWebSocketContainer.java:78)
at org.apache.tomcat.websocket.server.WsSci.init(WsSci.java:131)
at org.apache.tomcat.websocket.server.WsSci.onStartup(WsSci.java:47)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:184)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
... 6 more
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.res.StringManager from [Module "deployment.projectName.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 12 more
14:55:11,156 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "projectName.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host.\"projectName"" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host.\"projectName": java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager
Caused by: java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.res.StringManager from [Module \"deployment.projectName.war:main\" from Service Module Loader]"}}
14:55:11,187 INFO [org.jboss.as.server] (ServerService Thread Pool -- 37)
14:55:11,249 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.undertow.deployment.default-server.default-host."projectName": org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host."projectName": java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager
从jar文件转换为war时,我已经按照spring-boot documentation的建议进行操作。
具体地说,我已经声明了对spring-boot-starter-web的依赖,但不包括tomcat:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
我还导入了spring-boot-dependencies pom:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.4.RELEASE</version>
<type>pom</type>
<scope>import</scope>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
我还为spring-boot-starter-undertow添加了一个依赖项,其范围为:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<scope>provided</scope>
</dependency>
我删除了spring-boot-maven-plugin
,并使用SpringBootServletInitializer
覆盖扩展了我的应用程序类
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
我不明白为什么它不起作用,所以任何帮助将不胜感激。
答案 0 :(得分:0)
删除了底层依赖,起初没有用,但是后来我关闭了eclipse,然后重新打开就可以了。我真的不知道为什么会这样,但是确实可以。