Tuesday, August 23, 2016

Solution for error : java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri


Error :
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:626)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)


Pom.xml file

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.2</version>
</dependency>

Solution:
there is a conflict , you need to remove javax.ws.rs dependency .. anyway com.sun.jersy have the same classes to do the task.

3 comments:

  1. Thank u very much it worked when I removed my jsr311-api.

    ReplyDelete
  2. I have a requirement where I need to use both jersey 1.x and jersey 2.x
    Is there a way to have these dependencies added conditionally? I need both dependencies.

    ReplyDelete
  3. Thank you so much, @Gobi. As soon as I removed the javax.ws.rs dependency, tomcat was able to function as expected. Thanks a lot.

    ReplyDelete