WAR 无法在 AWS 中的 jetty9 上启动,但可以在本地安装
WAR fails to start on jetty9 in AWS but works on local installation
我有一个生成 .war
应用程序的 Maven 项目。当我在本地安装的 jetty9 中部署此 war 时,该应用程序可以正常工作。当我在 AWS 中部署到我的机器时,它无法启动并出现以下错误。
2017-07-05 17:53:43.336:WARN:oejuc.AbstractLifeCycle:main: FAILED o.e.j.w.WebAppContext@3dd3bcd{/my-app,file:/var/cache/jetty9/data/jetty-0.0.0.0-8080-my-app.war-_my-app-any-5436545420435013189.dir/webapp/,STARTING}{/my-app.war}: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:331)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
这是一个 Jersey 2 应用程序,它通过一个用 Jersey 1 编写的旧客户端与另一个 api 通信。我已经在两个版本的 Jersey 之间遇到冲突并使用 Maven 排除解决了它们 ,这在本地解决了问题,但由于某种原因,现在我部署时它失败了。
我没能发现这两种环境之间的区别。我 运行 java -jar /usr/share/jetty9/start.java --version
两台机器的结果是相同的(我比较了一下):
Jetty Server Classpath:
-----------------------
Version Information on 38 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
changes to the --module=name command line options will be reflected here.
0: (none specified) | ${jetty.home}/eclipse-ecj-3.11.0.jar
1: 9.2.18.v20160721 | ${jetty.home}/jetty9-apache-jsp.jar
2: 1.2.5 | ${jetty.home}/taglibs-standard-impl.jar
3: 1.2.5 | ${jetty.home}/taglibs-standard-spec.jar
4: 8.0.37 | ${jetty.home}/tomcat8-api-8.0.37.jar
5: 3.0.FR | ${jetty.home}/tomcat8-el-api-8.0.37.jar
6: 8.0.37 | ${jetty.home}/tomcat8-jasper-8.0.37.jar
7: 8.0.37 | ${jetty.home}/tomcat8-jasper-el-8.0.37.jar
8: 2.3.FR | ${jetty.home}/tomcat8-jsp-api-8.0.37.jar
9: 8.0.37 | ${jetty.home}/tomcat8-juli-8.0.37.jar
10: 8.0.37 | ${jetty.home}/tomcat8-util-8.0.37.jar
11: 8.0.37 | ${jetty.home}/tomcat8-util-scan-8.0.37.jar
12: (dir) | ${jetty.base}/resources
13: 3.1.FR | ${jetty.home}/servlet-api-3.1.jar
14: 9.2.18.v20160721 | ${jetty.home}/jetty9-http.jar
15: 9.2.18.v20160721 | ${jetty.home}/jetty9-server.jar
16: 9.2.18.v20160721 | ${jetty.home}/jetty9-xml.jar
17: 9.2.18.v20160721 | ${jetty.home}/jetty9-util.jar
18: 9.2.18.v20160721 | ${jetty.home}/jetty9-io.jar
19: 9.2.18.v20160721 | ${jetty.home}/jetty9-jndi.jar
20: 1.5.6 | ${jetty.home}/javax.mail.jar
21: 9.2.18.v20160721 | ${jetty.home}/jetty9-security.jar
22: 9.2.18.v20160721 | ${jetty.home}/jetty9-servlet.jar
23: 9.2.18.v20160721 | ${jetty.home}/jetty9-webapp.jar
24: 9.2.18.v20160721 | ${jetty.home}/jetty9-deploy.jar
25: 9.2.18.v20160721 | ${jetty.home}/jetty9-plus.jar
26: 9.2.18.v20160721 | ${jetty.home}/jetty9-annotations.jar
27: 3.0.FR | ${jetty.home}/tomcat8-annotations-api-8.0.37.jar
28: 5.1 | ${jetty.home}/asm-commons-5.1.jar
29: 5.1 | ${jetty.home}/asm-5.1.jar
30: 1.1.FR | ${jetty.home}/tomcat8-websocket-api-8.0.37.jar
31: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-client-impl.jar
32: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-server-impl.jar
33: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-api.jar
34: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-client.jar
35: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-common.jar
36: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-server.jar
37: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-servlet.jar
我的问题是:AWS 机器有什么不同可能导致此错误?我还应该去哪里寻找更多信息来解决这个问题?
显然排除项配置不正确。我排除了 com.sun.jersey:jersey-server
,但 javax.ws.rs:jsr311-api
作为 com.sun.jersey:jersey-client
的传递依赖项被包括在内。我明确排除了 javax.ws.rs:jsr311-api
并且有效。
我仍然不知道为什么它在我的本地码头安装中工作。一位队友建议这可能与每台机器上加载 jar 的顺序有关,但我不确定如何检查。
我有一个生成 .war
应用程序的 Maven 项目。当我在本地安装的 jetty9 中部署此 war 时,该应用程序可以正常工作。当我在 AWS 中部署到我的机器时,它无法启动并出现以下错误。
2017-07-05 17:53:43.336:WARN:oejuc.AbstractLifeCycle:main: FAILED o.e.j.w.WebAppContext@3dd3bcd{/my-app,file:/var/cache/jetty9/data/jetty-0.0.0.0-8080-my-app.war-_my-app-any-5436545420435013189.dir/webapp/,STARTING}{/my-app.war}: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:331)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
这是一个 Jersey 2 应用程序,它通过一个用 Jersey 1 编写的旧客户端与另一个 api 通信。我已经在两个版本的 Jersey 之间遇到冲突并使用 Maven 排除解决了它们
我没能发现这两种环境之间的区别。我 运行 java -jar /usr/share/jetty9/start.java --version
两台机器的结果是相同的(我比较了一下):
Jetty Server Classpath:
-----------------------
Version Information on 38 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
changes to the --module=name command line options will be reflected here.
0: (none specified) | ${jetty.home}/eclipse-ecj-3.11.0.jar
1: 9.2.18.v20160721 | ${jetty.home}/jetty9-apache-jsp.jar
2: 1.2.5 | ${jetty.home}/taglibs-standard-impl.jar
3: 1.2.5 | ${jetty.home}/taglibs-standard-spec.jar
4: 8.0.37 | ${jetty.home}/tomcat8-api-8.0.37.jar
5: 3.0.FR | ${jetty.home}/tomcat8-el-api-8.0.37.jar
6: 8.0.37 | ${jetty.home}/tomcat8-jasper-8.0.37.jar
7: 8.0.37 | ${jetty.home}/tomcat8-jasper-el-8.0.37.jar
8: 2.3.FR | ${jetty.home}/tomcat8-jsp-api-8.0.37.jar
9: 8.0.37 | ${jetty.home}/tomcat8-juli-8.0.37.jar
10: 8.0.37 | ${jetty.home}/tomcat8-util-8.0.37.jar
11: 8.0.37 | ${jetty.home}/tomcat8-util-scan-8.0.37.jar
12: (dir) | ${jetty.base}/resources
13: 3.1.FR | ${jetty.home}/servlet-api-3.1.jar
14: 9.2.18.v20160721 | ${jetty.home}/jetty9-http.jar
15: 9.2.18.v20160721 | ${jetty.home}/jetty9-server.jar
16: 9.2.18.v20160721 | ${jetty.home}/jetty9-xml.jar
17: 9.2.18.v20160721 | ${jetty.home}/jetty9-util.jar
18: 9.2.18.v20160721 | ${jetty.home}/jetty9-io.jar
19: 9.2.18.v20160721 | ${jetty.home}/jetty9-jndi.jar
20: 1.5.6 | ${jetty.home}/javax.mail.jar
21: 9.2.18.v20160721 | ${jetty.home}/jetty9-security.jar
22: 9.2.18.v20160721 | ${jetty.home}/jetty9-servlet.jar
23: 9.2.18.v20160721 | ${jetty.home}/jetty9-webapp.jar
24: 9.2.18.v20160721 | ${jetty.home}/jetty9-deploy.jar
25: 9.2.18.v20160721 | ${jetty.home}/jetty9-plus.jar
26: 9.2.18.v20160721 | ${jetty.home}/jetty9-annotations.jar
27: 3.0.FR | ${jetty.home}/tomcat8-annotations-api-8.0.37.jar
28: 5.1 | ${jetty.home}/asm-commons-5.1.jar
29: 5.1 | ${jetty.home}/asm-5.1.jar
30: 1.1.FR | ${jetty.home}/tomcat8-websocket-api-8.0.37.jar
31: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-client-impl.jar
32: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-server-impl.jar
33: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-api.jar
34: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-client.jar
35: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-common.jar
36: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-server.jar
37: 9.2.18.v20160721 | ${jetty.home}/jetty9-websocket-servlet.jar
我的问题是:AWS 机器有什么不同可能导致此错误?我还应该去哪里寻找更多信息来解决这个问题?
显然排除项配置不正确。我排除了 com.sun.jersey:jersey-server
,但 javax.ws.rs:jsr311-api
作为 com.sun.jersey:jersey-client
的传递依赖项被包括在内。我明确排除了 javax.ws.rs:jsr311-api
并且有效。
我仍然不知道为什么它在我的本地码头安装中工作。一位队友建议这可能与每台机器上加载 jar 的顺序有关,但我不确定如何检查。