如何在 jboss 7 中部署在 java 1.8 中编译的 war

how to deploy war compiled in java 1.8 in jboss 7

我已经将 java 1.7 早期的 Web 应用程序升级到 java 1.8。但是,当我尝试在 jboss 7 中部署它的 war 时, 我收到以下异常。

[jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_17]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]

18:49:41,659 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/nlp_Server]] (MSC service thread 1-8) Skipped installing application listeners due to previous error(s)
18:49:41,659 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Error listenerStart
18:49:41,659 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Context [/nlp_Server] startup failed due to previous errors
18:49:41,675 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.web.deployment.default-host./nlp_Server: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./nlp_Server: JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_17]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]

18:49:41,675 INFO  [org.jboss.as] (MSC service thread 1-4) JBAS015951: Admin console listening on http://127.0.0.1:9990
18:49:41,675 ERROR [org.jboss.as] (MSC service thread 1-4) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 4540ms - Started 213 of 294 services (2 services failed or missing dependencies, 78 services are passive or on-demand)
18:49:41,909 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "nlp_Server.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./nlp_Server" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./nlp_Server: JBAS018040: Failed to start context"}}
18:49:41,924 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015871: Deploy of deployment "MemberManagement.war" was rolled back with no failure message
18:49:41,971 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment MemberManagement.war in 48ms
18:49:42,018 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment nlp_Server.war in 128ms
18:49:42,018 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host./nlp_Server: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./nlp_Server: JBAS018040: Failed to start context

18:49:42,018 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS014654: Composite operation was rolled back
18:49:42,018 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./nlp_Server" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./nlp_Server: JBAS018040: Failed to start context"}}}}
18:49:44,732 INFO  [org.jboss.as.osgi] (MSC service thread 1-8) JBAS011942: Stopping OSGi Framework

相同的 war 正在 tomcat 中成功部署。

你的 Jboss 似乎 运行 JDK 7.

来自您的日志:

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17]

但是您使用 JDK 8 编译源代码,因此 JDK7 不能 运行 来自 JDK 8.

的编译代码

编译源码时请添加source和target。

例如javac -source 1.7 -target 1.7

我找到了答案。 jboss 7 不支持 jdk 1.8 本身。我已经下载了 jboss-eap-6.4.0,它支持 jdk 1.8。 我的应用程序现在可以正常工作了。