当我在Tomcat 8上使用JDK 8从Eclipse运行我的Web项目时,一切都运行良好,但是一旦我构建了这个项目并将WAR部署到服务器上的Tomcat 8,我就会收到以下错误:
java.lang.IncompatibleClassChangeError: com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider and com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl disagree on InnerClasses attribute
我已经尝试了一切,但它仍然没有用。
这是我的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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>RestWebService</groupId>
<artifactId>RestWebService</artifactId>
<version>0.1.0</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.17.1</version>
</dependency>
</dependencies>
</project>
以下是项目中所有JAR文件的列表:
asm-3.3.1.jar
jersey-bundle-1.19.jar
jsr311-api-1.1.1.jar
json-20140107.jar
jersey-server-1.19.jar
jersey-core-1.19.jar
gson-2.5.jar
sqljdbc4-4.0.jar
jersey-json-1.17.1.jar
jettison-1.1.jar
jaxb-impl-2.2.3-1.jar
jaxb-api-2.2.2.jar
stax-api-1.0-2.jar
activation-1.1.jar
jackson-core-asl-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-xc-1.9.2.jar
答案 0 :(得分:5)
看起来它是依赖版本的问题
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.17.1</version>
</dependency>
上述内容应与您所有其他Jersey依赖项的版本相同。所以只需将其更改为1.19
即可。