Jersey java.lang.AbstractMethodError:javax.ws.rs.core.UriBuilder.uri
我试图启动应用程序,但使用了Tomcat7,我遇到了这样一个异常 我认为这可能与Jersey java.lang.AbstractMethodError:javax.ws.rs.core.UriBuilder.uri,jersey,jax-rs,abstractmethoderror,Jersey,Jax Rs,Abstractmethoderror,我试图启动应用程序,但使用了Tomcat7,我遇到了这样一个异常 我认为这可能与Maven依赖关系有关,但我敢肯定。如果有人知道发生了什么,请回答:) 例外情况: message Servlet execution threw an exception description The server encountered an internal error that prevented it from fulfilling this request. exception javax.ser
Maven依赖关系有关,但我敢肯定。如果有人知道发生了什么,请回答:)
例外情况:
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:651)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.50 logs.
Maven POM
:
<properties>
<application.version>1.0</application.version>
<spring.version>4.0.0.RELEASE</spring.version>
<spring.security.version>3.2.0.RELEASE</spring.security.version>
<jersey.version>1.18.1</jersey.version>
</properties>
<dependencies>
<dependency>
<groupId>climbing-portal-facade</groupId>
<artifactId>climbing-portal-facade</artifactId>
<version>${application.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</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-json</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jdk-http</artifactId>
<version>2.7</version>
</dependency>
<!-- Jersey + Spring -->
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>${jersey.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
1
4.0.0.0发布
3.2.0.1发布
1.18.1
攀爬式入口立面
攀爬式入口立面
${application.version}
泽西岛
球衣核心
${jersey.version}
泽西岛
泽西服务器
${jersey.version}
泽西岛
泽西json
${jersey.version}
org.glassfish.jersey.test-framework.providers
jersey测试框架提供程序jdk http
2.7
com.sun.jersey.contribs
泽西之春
${jersey.version}
org.springframework
春天
org.springframework
弹簧芯
org.springframework
弹簧网
org.springframework
春豆
org.springframework
spring上下文
org.springframework
春季aop
org.springframework
弹簧网
${spring.version}
有什么想法吗?您同时使用了Jersey 1和(Jersey 1是一个显式依赖项,Jersey 2是Jersey测试框架提供程序jdk http
的一个可传递依赖项),这是不可能的-因此类加载器选择了错误的URIBuilder
类
com.sun.Jersey
组中的Jersey
依赖项都是Jersey版本1
。
Jersey版本2
使用组org.glassfish.Jersey
您的Maven
依赖项中都有这两个项,这导致了此问题
如有可能,仅使用球衣2 这也可能是由于将两者都包括在内而导致的
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.xxx</version>
</dependency>
泽西岛
.我有确切的问题,但找不到问题。
第一次启动Tomcat时,一切正常,但重启服务器之后
我有个例外
解决方案是将tomcat降级到7.0.26,但不知道为什么。我解决了这个问题:我删除了JAX-RS 2.0库,添加了jersey-server-1.8.jar库、jersey-core-1.8.jar库、jersey-servlet-1.12.jar库和asm-3.3.1.jar库。我没有意识到这一点,但是服务器上的WEB-INF/lib文件夹中已经有一个名为javax.ws-rs-api-2.0.jar的文件。它是两年前由其他人添加的。它与我复制到WEB-INF/lib文件夹的jersey文件集发生冲突。我备份/重命名了文件,为我的容器(即Tomcat)重新启动了服务,它工作了。在我的例子中,jsr311-api-0.10.jar和javax.ws.rs-api-2.0.jar都在应用程序库中。我删除了jsr311 jar,问题解决了我们需要做以下更改:
web.xml
RESTfulWeb服务示例
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
com.subu.jersey.rest
pom.xml
org.glassfish.jersey.core
泽西服务器
2.17
org.glassfish.jersey.containers
jersey容器servlet核心
2.17
在我的例子中,jsr311-api-0.10.jar和javax.ws.rs-api-2.1.jar都在应用程序库中。我删除了javax.ws.rs-api-2.1.jar,问题就解决了您是否像上面所说的那样查看了ApacheTomcat/7.0.50日志?下面是javadoc所说的:“当应用程序试图调用抽象方法时抛出。通常,编译器会捕获此错误;只有在运行时,如果自上次编译当前执行的方法以来某个类的定义发生了不兼容的更改,才会发生此错误。”因此,这可能是某种类型的类路径错误。netbeans会因为没有提供“我知道”下的版本信息而向您抛出错误。maven需要版本,但我没有使用它们,因为答案是版本不可知的,删除它们可能会更容易找到Google@rogerdpack在这一点上,这可能是你的答案为声誉的目的。你添加了太多我没有的上下文信息。我有Netbeans 8.02、weblogic 11g、oracle server 11gby“library JAX-RS”,我想你是指一个名为RS api之类的jar文件?我也有同样的问题,多亏了你的评论!没有意识到我的部署脚本没有删除旧文件。
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.xx</version>
</dependency>
<servlet>
<servlet-name>RESTful Jersey Web Service Sample</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.subu.jersey.rest</param-value>
</init-param>
</servlet>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>