当我尝试运行REST服务时,我得到了找不到方法的服务。我使用Jersey 2.11和Jboss 7.1。泽西岛1.8工作正常。
pom.xml
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.11</version>
</dependency>
web.xml
<servlet>
<servlet-name>Jersey</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>app.rest.RefreshDatabaseService</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
RefreshDatabaseService.java
@Path("refresh")
public class RefreshDatabaseService extends ResourceConfig {
private static Logger logger = Logger.getLogger(RefreshDatabaseService.class);
public RefreshDatabaseService() {
packages("com.jtendo.notification.app.rest.RefreshDatabaseService");
}
@GET
@Path("all")
public String refreshAllTable() {
日志
12:55:29,502 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/NotificationGW-app]] (MSC service thread 1-3)() Servlet /NotificationGW-app threw load() exception: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304) [jersey-server-2.11.jar:]
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285) [jersey-server-2.11.jar:]
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:310) [jersey-container-servlet-core-2.11.jar:]
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170) [jersey-container-servlet-core-2.11.jar:]
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358) [jersey-container-servlet-core-2.11.jar:]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_65]
我正在跑http://localhost:8080/app/rest/refresh/all
。
在我的war文件的lib
文件夹中,我没有看到不同版本中的任何重复的jar文件。所有球衣均为2.11版本。
答案 0 :(得分:0)
你可能有两个带有javax.ws.rs.core.Application
类的jar文件,其中一个(遗憾的是由java发现)没有getPropetries
方法。
尝试使用 JHades 查找重叠的jar并删除错误的jar。