我有一个maven RESTful Web服务应用程序(支持JAX-RS)。当我在Tomcat v7.0服务器上运行它时,我的API工作正常。但是,当我在Bluemix中使用的WebSphere Liberty Server上部署相同项目时出现错误。
部署应用程序时,它会毫无问题地加载。我也可以打开index.jsp页面。它甚至可以完美地运行一些API请求调用(通常是不接受任何输入的请求,不会产生输出。但是,对于某些API请求,它会显示此错误:
Launching defaultServer (WebSphere Application Server 8.5.5.9/wlp-1.0.12.cl50920160227-1523) on Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_60-b27 (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.9/lafiles/en.html
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT ] CWWKI0001I: The CORBA name server is now available at corbaloc:iiop:localhost:2809/NameService.
[AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/congEst/
[AUDIT ] CWWKZ0001I: Application congEst started in 11.912 seconds.
[AUDIT ] CWWKF0012I: The server installed the following features: [servlet-3.1, beanValidation-1.1, ssl-1.0, jndi-1.0, jca-1.7, ejbPersistentTimer-3.2, appSecurity-2.0, j2eeManagement-1.1, jdbc-4.1, wasJmsServer-1.0, jaxrs-2.0, javaMail-1.5, cdi-1.2, webProfile-7.0, jcaInboundSecurity-1.0, jpa-2.1, jsp-2.3, ejbLite-3.2, managedBeans-1.0, jsf-2.2, ejbHome-3.2, jaxws-2.2, localConnector-1.0, jsonp-1.0, el-3.0, jaxrsClient-2.0, concurrent-1.0, appClientSupport-1.0, ejbRemote-3.2, javaee-7.0, jaxb-2.2, mdb-3.2, jacc-1.5, batch-1.0, ejb-3.2, json-1.0, jaspic-1.1, distributedMap-1.0, websocket-1.1, wasJmsSecurity-1.0, wasJmsClient-2.0].
[AUDIT ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.
[ERROR ] SRVE0777E: Exception thrown by application class 'org.glassfish.jersey.servlet.WebComponent.service:419'
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/eclipse/persistence/jaxb/compiler/Generator.generateSchemaFiles(Ljava/lang/String;Ljava/util/Map;)Ljava/util/HashMap; @90: invokevirtual
Reason:
Type 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject' (current frame, stack[0]) is not assignable to 'org/eclipse/persistence/core/sessions/CoreProject'
Current Frame:
bci: @90
flags: { }
locals: { 'org/eclipse/persistence/jaxb/compiler/Generator', 'java/lang/String', 'java/util/Map', 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject', 'org/eclipse/ persistence/oxm/XMLContext', 'org/eclipse/persistence/oxm/XMLMarshaller' }
stack: { 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject', 'java/lang/Class' }
Bytecode:
0x0000000: 2a2c 2ab4 015a b701 862a b401 5c2a b401
0x0000010: 5ab6 0175 2ab4 015a b601 792a b401 5ab6
0x0000020: 017b 2ab4 015a b601 782a b401 5ab6 0176
0x0000030: 2ab4 015a b601 7db6 018d 57bb 00b2 59b7
0x0000040: 016b 4ebb 00be 592d c000 c0b7 0195 3a04
0x0000050: 1904 b601 943a 052d 1202 b601 6ac0 00b1
0x0000060: 3a06 2ab4 015c b601 8a3a 0719 07b9 0198
0x0000070: 0100 3a09 a700 5e19 09b9 019a 0100 c000
0x0000080: 023a 08bb 009c 59bb 00a5 592b b801 62b7
0x0000090: 0164 1201 b601 6519 08b6 016d b601 65b6
0x00000a0: 0163 b701 5e3a 0a19 08b6 0170 3a0b 190b
0x00000b0: 1300 9913 0098 b601 9319 0619 0bb9 01a2
0x00000c0: 0200 1905 1908 bb00 9e59 190a b701 5fb6
0x00000d0: 0196 1909 b901 9901 009a ff9e 2ab4 015c
0x00000e0: b601 8bb0
Stackmap Table:
full_frame(@119,{Object[#182],Object[#164],Object[#170],Object[#176],Object[#190],Object[#191],Object[#177],Object[#167],Top,Object[#169]},{})
same_frame_extended(@210)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:419)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1290)
at [internal classes]
Caused by: org.glassfish.jersey.server.ContainerException: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/eclipse/persistence/jaxb/compiler/Generator.generateSchemaFiles(Ljava/lang/String;Ljava/util/Map;)Ljava/util/HashMap; @90: invokevirtual
Reason:
Type 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject' (current frame, stack[0]) is not assignable to 'org/eclipse/persistence/core/sessions/CoreProject'
Current Frame:
bci: @90
flags: { }
locals: { 'org/eclipse/persistence/jaxb/compiler/Generator', 'java/lang/String', 'java/util/Map', 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject', 'org/eclipse/ persistence/oxm/XMLContext', 'org/eclipse/persistence/oxm/XMLMarshaller' }
stack: { 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject', 'java/lang/Class' }
Bytecode:
0x0000000: 2a2c 2ab4 015a b701 862a b401 5c2a b401
0x0000010: 5ab6 0175 2ab4 015a b601 792a b401 5ab6
0x0000020: 017b 2ab4 015a b601 782a b401 5ab6 0176
0x0000030: 2ab4 015a b601 7db6 018d 57bb 00b2 59b7
0x0000040: 016b 4ebb 00be 592d c000 c0b7 0195 3a04
0x0000050: 1904 b601 943a 052d 1202 b601 6ac0 00b1
0x0000060: 3a06 2ab4 015c b601 8a3a 0719 07b9 0198
0x0000070: 0100 3a09 a700 5e19 09b9 019a 0100 c000
0x0000080: 023a 08bb 009c 59bb 00a5 592b b801 62b7
0x0000090: 0164 1201 b601 6519 08b6 016d b601 65b6
0x00000a0: 0163 b701 5e3a 0a19 08b6 0170 3a0b 190b
0x00000b0: 1300 9913 0098 b601 9319 0619 0bb9 01a2
0x00000c0: 0200 1905 1908 bb00 9e59 190a b701 5fb6
0x00000d0: 0196 1909 b901 9901 009a ff9e 2ab4 015c
0x00000e0: b601 8bb0
Stackmap Table:
full_frame(@119,{Object[#182],Object[#164],Object[#170],Object[#176],Object[#190],Object[#191],Object[#177],Object[#167],Top,Object[#169]},{})
same_frame_extended(@210)
at org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:256)
at org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:238)
at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:480)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:311)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:286)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1072)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:399)
... 5 more
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
org/eclipse/persistence/jaxb/compiler/Generator.generateSchemaFiles(Ljava/lang/String;Ljava/util/Map;)Ljava/util/HashMap; @90: invokevirtual
Reason:
Type 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject' (current frame, stack[0]) is not assignable to 'org/eclipse/persistence/core/sessions/CoreProject'
Current Frame:
bci: @90
flags: { }
locals: { 'org/eclipse/persistence/jaxb/compiler/Generator', 'java/lang/String', 'java/util/Map', 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject', 'org/eclipse/ persistence/oxm/XMLContext', 'org/eclipse/persistence/oxm/XMLMarshaller' }
stack: { 'org/eclipse/persistence/internal/oxm/schema/SchemaModelProject', 'java/lang/Class' }
Bytecode:
0x0000000: 2a2c 2ab4 015a b701 862a b401 5c2a b401
0x0000010: 5ab6 0175 2ab4 015a b601 792a b401 5ab6
0x0000020: 017b 2ab4 015a b601 782a b401 5ab6 0176
0x0000030: 2ab4 015a b601 7db6 018d 57bb 00b2 59b7
0x0000040: 016b 4ebb 00be 592d c000 c0b7 0195 3a04
0x0000050: 1904 b601 943a 052d 1202 b601 6ac0 00b1
0x0000060: 3a06 2ab4 015c b601 8a3a 0719 07b9 0198
0x0000070: 0100 3a09 a700 5e19 09b9 019a 0100 c000
0x0000080: 023a 08bb 009c 59bb 00a5 592b b801 62b7
0x0000090: 0164 1201 b601 6519 08b6 016d b601 65b6
0x00000a0: 0163 b701 5e3a 0a19 08b6 0170 3a0b 190b
0x00000b0: 1300 9913 0098 b601 9319 0619 0bb9 01a2
0x00000c0: 0200 1905 1908 bb00 9e59 190a b701 5fb6
0x00000d0: 0196 1909 b901 9901 009a ff9e 2ab4 015c
0x00000e0: b601 8bb0
Stackmap Table:
full_frame(@119,{Object[#182],Object[#164],Object[#170],Object[#176],Object[#190],Object[#191],Object[#177],Object[#167],Top,Object[#169]},{})
same_frame_extended(@210)
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:1017)
at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:174)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:165)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:152)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:112)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:102)
at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.getJAXBContext(MOXyJsonProvider.java:302)
at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.readFrom(MOXyJsonProvider.java:557)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:259)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:235)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:74)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1075)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:853)
at org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:270)
at org.glassfish.jersey.server.internal.inject.EntityParamValueFactoryProvider$EntityValueFactory.provide(EntityParamValueFactoryProvider.java:96)
at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:81)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:125)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:203)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:97)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:303)
... 14 more
...
...
...
我无法弄清楚问题。我在Google中搜索并意识到如果编译时环境与运行时环境不同,可能会发生此问题(VerifyError)。但是,我无法弄明白。
这是我的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>vanet</groupId>
<artifactId>congEst</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>congEst</name>
<build>
<finalName>congEst</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- <artifactId>jersey-container-servlet</artifactId> -->
</dependency>
<!-- uncomment this to get JSON support -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jfuzzylogic</groupId>
<artifactId>jFuzzyLogic</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<jersey.version>2.16</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
此文件是我的web.xml
文件。如果我想删除泽西实现,我应该在这个文件中替换什么?
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>vanet.congEst</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
</web-app>
更新
我做了以下更改,但仍然收到错误。
-web.xml:
<servlet>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>com.ibm.websphere.jaxrs.server.IBMRestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.core.Application</param-name>
<param-value>vanet.congEst</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
-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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>vanet</groupId>
<artifactId>congEst</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>congEst</name>
<build>
<finalName>congEst</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jfuzzylogic</groupId>
<artifactId>jFuzzyLogic</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere.appserver.api</groupId>
<artifactId>com.ibm.websphere.appserver.api.jaxrs</artifactId>
<version>1.0.10</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
</properties>
</project>
但是在向API发出请求时我收到此错误。 我的错误在哪里?
[AUDIT ] CWWKF0012I: The server installed the following features: [servlet-3.1, beanValidation-1.1, ssl-1.0, jndi-1.0, jca-1.7, ejbPersistentTimer-3.2, appSecurity-2.0, j2eeManagement-1.1, jdbc-4.1, wasJmsServer-1.0, jaxrs-2.0, javaMail-1.5, cdi-1.2, webProfile-7.0, jcaInboundSecurity-1.0, jpa-2.1, jsp-2.3, ejbLite-3.2, managedBeans-1.0, jsf-2.2, ejbHome-3.2, jaxws-2.2, localConnector-1.0, jsonp-1.0, el-3.0, jaxrsClient-2.0, concurrent-1.0, appClientSupport-1.0, ejbRemote-3.2, javaee-7.0, jaxb-2.2, mdb-3.2, jacc-1.5, batch-1.0, ejb-3.2, json-1.0, jaspic-1.1, distributedMap-1.0, websocket-1.1, wasJmsSecurity-1.0, wasJmsClient-2.0].
[AUDIT ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.
[ERROR ] SRVE0276E: Error while initializing Servlet [JAX-RS Servlet]: javax.servlet.UnavailableException: SRVE0203E: Servlet [JAX-RS Servlet]: com.ibm.websphere.jaxrs.server.IBMRestServlet was found, but is missing another required class.
SRVE0206E: This error typically implies that the servlet was originally compiled with classes which cannot be located by the server.
SRVE0187E: Check your class path to ensure that all classes required by the servlet are present.SRVE0210I: This problem can be debugged by recompiling the servlet using only the classes in the application's runtime class path
答案 0 :(得分:0)
In your pom.xml you are referencing the JAX/RS implementation of Glassfish/Jersey. This is no problem in Tomcat, because Tomcat is only a Servlet container, but Liberty is a full JEE application server, that comes with its own JAX/RS implementation based on Apache CXF and Jackson.
So first I would recommend that you install Liberty also locally to test your code before you ship it into Bluemix. Just go to liberty's download page.
Then you should remove all your Glassfish dependencies and change your pom.xml to use the following dependency:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
This is plain JEE and has no dependency on any vendor specific code. Look at this simple pom.xml. This would run in Liberty on Bluemix.