2017-04-26 4 views
0

나는 봄 mvc 및 저지 휴식 클라이언트 프로젝트 1 및 프로젝트 2를 봄 코어로 작업하고 있습니다. Tomcat 서버에서 코드를 실행하는 동안 예외가 발생합니다.java.lang.LinkageError : ClassCastException : 봄 MVC 프로젝트

예외 : 잡았다 던질 수는 ClassCastException가 : castjar 시도 : 파일 : /project1/web/webroot/WEB-INF/lib/jersey-core-1.13.jar를 /javax/ws/rs/ext/RuntimeDelegate.classtojar! : file : /project2/lib/jersey-core-1.13.jar! /javax/ws/rs/ext/RuntimeDelegate.class java.lang.LinkageError : ClassCastException : 캐스팅하려고 시도하는 중 : file :/project1/web/webroot/WEB-INF/lib/jersey-core-1.13.jar! /javax/ws/rs/ext/RuntimeDelegate.classtojar:file:/project2/lib/jersey-core-1.13.jar!/javax/ws/rs/ext/RuntimeDelegate.class

내 프로젝트 2 받는다는 종속성 :

<properties> 
      <jersey.version>1.13</jersey.version> 
     </properties> 

     <dependencies> 
      <dependency> 
       <groupId>com.sun.jersey</groupId> 
       <artifactId>jersey-core</artifactId> 
       <version>${jersey.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>com.sun.jersey</groupId> 
       <artifactId>jersey-client</artifactId> 
       <version>${jersey.version}</version> 
       <exclusions> 
        <exclusion> 
         <groupId>com.sun.jersey</groupId> 
         <artifactId>jersey-core</artifactId> 
        </exclusion> 
       </exclusions> 
      </dependency> 
      <dependency> 
       <groupId>org.json</groupId> 
       <artifactId>json</artifactId> 
       <version>20090211</version> 
      </dependency> 
      <dependency> 
       <groupId>com.fasterxml.jackson.module</groupId> 
       <artifactId>jackson-module-jaxb-annotations</artifactId> 
       <version>2.4.0</version> 
      </dependency> 

프로젝트 1 받는다는 종속성 :

<properties> 
     <jersey.version>1.13</jersey.version> 
    </properties> 

    <dependencies> 
      <dependency> 
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-core</artifactId> 
      <version>${jersey.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-client</artifactId> 
      <version>${jersey.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>com.sun.jersey</groupId> 
        <artifactId>jersey-core</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-json</artifactId> 
      <version>${jersey.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-server</artifactId> 
      <version>${jersey.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.jersey</groupId> 
      <artifactId>jersey-servlet</artifactId> 
      <version>${jersey.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.jersey.contribs</groupId> 
      <artifactId>jersey-spring</artifactId> 
      <version>${jersey.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.jersey.jersey-test-framework</groupId> 
      <artifactId>jersey-test-framework-core</artifactId> 
      <version>${jersey.version}</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.ws.rs</groupId> 
      <artifactId>jsr311-api</artifactId> 
      <version>1.1.1</version> 
     </dependency> 
<dependency> 
    <groupId>org.springframework.security.oauth</groupId> 
    <artifactId>spring-security-oauth2</artifactId> 
    <version>2.0.6.RELEASE</version> 
    <exclusions> 
       <exclusion> 
        <groupId>com.sun.jersey</groupId> 
        <artifactId>jersey-client</artifactId> 
       </exclusion> 
      </exclusions> 
</dependency> 
<dependency> 
    <groupId>net.sourceforge.javacsv</groupId> 
    <artifactId>javacsv</artifactId> 
    <version>2.0</version> 
</dependency> 

답변

0

당신은 두 프로젝트에서 jersy 존재하는 데. 이렇게하면 jersy 클래스를로드 할 다른 클래스 로더가 생기므로 클래스 캐스트 예외가 발생합니다. jersy가 한 번만로드되었는지 확인하십시오. jersy jar를 서버 라이브러리에 넣고 제공된대로 maven 범위를 사용하면됩니다.