2013-09-16 2 views
2

Кажется, у меня конфликт зависимости, который я не уверен, как его решить. Я пытаюсь реализовать Swagger в своем приложении. Я включил мой pom, а также трассировку стека. Если я могу включить что-нибудь еще, чтобы лучше описать проблему, сообщите мне. Я не уверен, как начать отладку этого ...NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getOsgiRegistryInstance() Lcom/sun/jersey/core/osgi/OsgiRegistry;

Exception in thread "main" java.lang.NoSuchMethodError: com.sun.jersey.core.reflection.ReflectionHelper.getOsgiRegistryInstance()Lcom/sun/jersey/core/osgi/OsgiRegistry; 
    at com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.getClassForName(AnnotationScannerListener.java:217) 
    at com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.visitEnd(AnnotationScannerListener.java:186) 
    at org.objectweb.asm.ClassReader.accept(Unknown Source) 
    at org.objectweb.asm.ClassReader.accept(Unknown Source) 
    at com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:136) 
    at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1.f(FileSchemeScanner.java:86) 
    at com.sun.jersey.core.util.Closing.f(Closing.java:71) 
    at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scanDirectory(FileSchemeScanner.java:83) 
    at com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scan(FileSchemeScanner.java:71) 
    at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:223) 
    at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:139) 
    at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80) 
    at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104) 
    at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78) 
    at com.api.Main.startServer(Main.java:30) 
    at com.api.Main.main(Main.java:52) 

pom.xml

<repositories> 
    <repository> 
     <id>maven2-repository.dev.java.net</id> 
     <name>Java.net Repository for Maven</name> 
     <url>http://download.java.net/maven/2/</url> 
     <layout>default</layout> 
    </repository> 
    <repository> 
     <id>spring-milestone</id> 
     <name>Spring Maven MILESTONE Repository</name> 
     <url>http://maven.springframework.org/milestone</url> 
    </repository> 
</repositories> 
<dependencies> 
    <dependency> 
     <groupId>org.glassfish.grizzly</groupId> 
     <artifactId>grizzly-http-servlet</artifactId> 
     <version>2.2.21</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.17</version> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.23</version> 
    </dependency> 

    <!-- Swagger --> 
    <dependency> 
     <groupId>com.wordnik</groupId> 
     <artifactId>swagger-core_2.10</artifactId> 
     <version>1.3.0</version> 
    </dependency> 
    <dependency> 
     <groupId>com.wordnik</groupId> 
     <artifactId>swagger-jersey-jaxrs_2.10</artifactId> 
     <version>1.3.0</version> 
     <exclusions> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>com.github.kongchen</groupId> 
     <artifactId>swagger-maven-plugin</artifactId> 
     <version>1.1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
    </dependency> 

    <!-- Jersey --> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-server</artifactId> 
     <version>1.17.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-json</artifactId> 
     <version>1.17.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-servlet</artifactId> 
     <version>1.17.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-grizzly2</artifactId> 
     <version>1.17.1</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-frontend-jaxrs</artifactId> 
     <version>2.7.6</version> 
    </dependency> 

    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-jaxrs</artifactId> 
     <version>1.9.13</version> 
    </dependency> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-xc</artifactId> 
     <version>1.9.13</version> 
    </dependency> 

    <!-- Hibernate/Spring --> 
    <dependency> 
     <groupId>org.hibernate.javax.persistence</groupId> 
     <artifactId>hibernate-jpa-2.0-api</artifactId> 
     <version>1.0.1.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-core</artifactId> 
     <version>4.2.5.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <version>4.2.5.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-annotations</artifactId> 
     <version>3.5.6-Final</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.2.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>3.2.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-jpa</artifactId> 
     <version>1.3.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.5</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-jdk14</artifactId> 
     <version>1.7.5</version> 
    </dependency> 
    <dependency> 
     <groupId>com.mysql</groupId> 
     <artifactId>management</artifactId> 
     <version>1.1.6</version> 
     <exclusions> 
      <exclusion> 
       <groupId>com.sun.jmx</groupId> 
       <artifactId>jmxri</artifactId> 
      </exclusion> 
      <exclusion> 
       <groupId>com.sun.jdmk</groupId> 
       <artifactId>jmxtools</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
</dependencies> 

ответ

6

Пожалуйста, добавьте явную зависимость к ядру джерси

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-core</artifactId> 
    <version>1.17.1</version> 
</dependency> 

В противном случае, джерси-жильный (V 1.13)

В качестве транзитивной зависимости от чартер-джерси-jaxrs используется старая версия (V 1.13).

Вы можете увидеть, запустив mvn dependency:tree до и после изменения

Это также верно для джерси-клиента и джерси расслоения в случае, если вы используете их