java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29134098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
提问by blueSky
All, I have a little REST project to learn REST. Following is pom.xml providing jars for Jersey and Javax. I use Tomcat 8.
所有,我有一个小的 REST 项目来学习 REST。以下是为 Jersey 和 Javax 提供 jars 的 pom.xml。我使用 Tomcat 8。
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
</dependencies>
When I try to run any of web services, I receive the following error.
当我尝试运行任何 Web 服务时,我收到以下错误。
I Google searched it and in most places, it says that it's a maven dependency/conflict issue bet. Jersey and JAX-RS API jars. I cannot find out what jars may conflict.
我谷歌搜索了它,在大多数地方,它说这是一个 maven 依赖/冲突问题赌注。Jersey 和 JAX-RS API jar。我无法找出哪些罐子可能会发生冲突。
Please note that I had no problem running these services a while ago… started to receive this error when I changed my laptop… upgraded to Tomcat 8, installed Eclipse Luna, still on Java 7.
请注意,我不久前运行这些服务没有问题......当我更换笔记本电脑时开始收到此错误......升级到Tomcat 8,安装Eclipse Luna,仍然使用Java 7。
I can't figure out what might have gone wrong… please let me know if you have any idea. Any help is greatly appreciated.
我无法弄清楚可能出了什么问题……如果您有任何想法,请告诉我。任何帮助是极大的赞赏。
exception
javax.servlet.ServletException: Servlet execution threw an exception
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
: Servlet.service() for servlet [Jersey Servlet] in context with path [/restfulAPI] threw exception [Servlet execution threw an exception] with root cause
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:662)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
采纳答案by blueSky
Although I don't know why it used to work with Tomcat 6 and started giving the above exception when upgraded to Tomcat 8, however, removed:
虽然我不知道为什么它曾经与 Tomcat 6 一起使用并在升级到 Tomcat 8 时开始给出上述异常,但是,删除了:
javaee-api 7.0
jar and added:
jar 并添加:
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
The above exception went away. In order to have the consistency bet. Jersey client and server jars, used:
上述异常消失了。为了有一致性的赌注。Jersey 客户端和服务器 jars,使用:
jersey-server 1.10
jar but received this error:
jar 但收到此错误:
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
When put the:
当把:
jersey-server 1.9
back, exception went away and the REST services started working again.
回来,异常消失了,REST 服务再次开始工作。
Please note, if your application, needs other jars from javaee-api, add each jar individually; looks like javaee-api package jar can't co-exist with Jersey 1.
请注意,如果您的应用程序需要 javaee-api 中的其他 jar,请单独添加每个 jar;看起来 javaee-api 包 jar 不能与 Jersey 1 共存。
回答by user3465058
HI have faced the issue using weblogic 10.3 then i have just removed the javax.ws jar and its dependencies then my application is running fine
HI 使用 weblogic 10.3 遇到了这个问题,然后我刚刚删除了 javax.ws jar 及其依赖项,然后我的应用程序运行良好
回答by K?re Jonsson
I got this when upgrading jersey 1.17 -> 1.19. Tried jersey 2 but the examples did not work. After considerable time I downgraded to 1.17.
我在升级球衣 1.17 -> 1.19 时得到了这个。试过球衣 2,但示例不起作用。经过相当长的时间,我降级到 1.17。