Spring Jersey:java.lang.NoSuchMethodError:org.glassfish.jersey.server.ServerProperties.getValue?

我的web.xml看起来像

<web-app >
    <servlet>
        <servlet-name>InventoryApplication</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>InventoryApplication</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
</web-app>

和端点为

@Component
@Path("/hello")
public class HelloResource {

    @GET
    public void hello() {
        System.out.println("REQUEST RECEIVED");

    }
}

当我使用货物作为mvn:货物:运行部署时,我看到错误为

[INFO] [talledLocalContainer] May 03, 2014 5:09:59 PM org.apache.catalina.core.StandardWrapperValve invoke
[INFO] [talledLocalContainer] SEVERE: Allocate exception for servlet com.yahoo.pryme_services.inventory.services.InventoryApplication
[INFO] [talledLocalContainer] java.lang.NoSuchMethodError: org.glassfish.jersey.server.ServerProperties.getValue(Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
[INFO] [talledLocalContainer]   at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:315)
[INFO] [talledLocalContainer]   at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
[INFO] [talledLocalContainer]   at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
[INFO] [talledLocalContainer]   at javax.servlet.GenericServlet.init(GenericServlet.java:158)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:864)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
[INFO] [talledLocalContainer]   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
[INFO] [talledLocalContainer]   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
[INFO] [talledLocalContainer]   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
[INFO] [talledLocalContainer]   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
[INFO] [talledLocalContainer]   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
[INFO] [talledLocalContainer]   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
[INFO] [talledLocalContainer]   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:745)
[INFO] [talledLocalContainer] 

这是怎么回事?

解决方法:

在没有调整Jersey版本的情况下切换到最近的Grizzly容器版本时遇到了同样的问题.

在我的具体案例中,

<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.15</version>

与…发生冲突

<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>2.7</version>

用球衣来回到2.15解决了这个问题.

上一篇:java – Spring Boot上的Jersey – ApplicationPath


下一篇:java – @ValidateOnExecution什么时候应该和泽西一起使用?