Apache Jersey异常:java.lang.NoSuchMethodError:org.glassfish.hk2.utilities.AbstractActiveDescriptor

时间:2016-05-03 15:47:39

标签: java jersey jersey-2.0

我正在使用Jersey Framework学习Java rest webservices。  在eclipse中创建了一个示例项目,但无法在tomcat中部署它。在eclipse项目中添加了以下库。谁能请你帮帮我

cglib-2.2.jar
hk2-api-2.3.0-b06.jar
hk2-locator-2.1.63.jar
hk2-utils-2.5.0-b04.jar
javassist.jar
javax-inject.jar
javax.annotation-api-1.2.jar
javax.ws.rs-api-2.0.jar
javax.ws.rs.jar
jersey-bean-validation-2.17.jar
jersey-client.jar
jersey-common.jar
jersey-container-servlet-core.jar
jersey-container-servlet.jar
jersey-guava-2.7.jar
jersey-media-jaxb.jar
jersey-server.jar
validation-api-1.0.0.GA.jar

Getting below error while running project in Apache server inside eclipse.

       SEVERE: StandardWrapper.Throwable
    java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.AbstractActiveDescriptor.<init>(Ljava/util/Set;Ljava/lang/Class;Ljava/lang/String;L
    java/util/Set;Lorg/glassfish/hk2/api/DescriptorType;Lorg/glassfish/hk2/api/DescriptorVisibility;ILjava/lang/Boolean;Ljava/lang/String;Ljava/
    util/Map;)V
        at org.jvnet.hk2.internal.ConstantActiveDescriptor.<init>(ConstantActiveDescriptor.java:113)
        at org.jvnet.hk2.internal.Utilities.getLocatorDescriptor(Utilities.java:951)
        at org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.initialize(ServiceLocatorGeneratorImpl.java:71)
        at org.jvnet.hk2.external.generator.ServiceLocatorGeneratorImpl.create(ServiceLocatorGeneratorImpl.java:96)
        at org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.internalCreate(ServiceLocatorFactoryImpl.java:270)
        at org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.create(ServiceLocatorFactoryImpl.java:230)
        at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
        at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:330)
        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)
        at javax.servlet.GenericServlet.init(GenericServlet.java:158)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5253)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5543)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source) enter code here

1 个答案:

答案 0 :(得分:0)

如果您看到异常

Apache Jersey exception:java.lang.NoSuchMethodError : org.glassfish.hk2.utilities.AbstractActiveDescriptor

根据我的经验,由于不兼容的jar,此异常NoSuchMethodError已添加到您的项目library中。

使用最新的jar hk2-api-2.5.0-b04.jar代替hk2-api-2.3.0-b06.jar。这可能会解决你的问题..