• Post Reply Bookmark Topic Watch Topic
  • New Topic

REST WebService using JAX-RS

 
Roopesh Rana
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a simple REST web service in JAVA using JAX-RS. But I am getting runtime error,
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;


web.xml



Java Classes

Todo.java



TodoDao.java



create_todo.html



TodoResource.java



TodosResource.java

package de.vogella.jersey.todo.resources;





I am getting Error :
javax.servlet.ServletException: Servlet execution threw an exception


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:662)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)



I am using Tomcat 6.X

Please help me to resolve this problem

 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of Jersey Core library are you using? Most likely this issue is a dependency inconsistency.
 
Roopesh Rana
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using jaxrs-ri-2.9
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roopesh Rana wrote:
I am using jaxrs-ri-2.9

And I would hazard your tomcat 6.X is using Java SE 6, right?
Jersey 2.9 User Guide wrote: Until version 2.6, Jersey was compiled with Java SE 6. This has changes in Jersey 2.7. Now almost all Jersey components are compiled with Java SE 7 target. It means, that you will need at least Java SE 7 to be able to compile and run your application that is using latest Jersey. Only core-common and core-client modules are still compiled with Java class version runnable with Java SE 6.
 
Anindya Roy
Ranch Hand
Posts: 76
 
Roopesh Rana
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Anindya Roy,

I am trying to run your given example, but I getting below exception in RestTest.java class.


java.lang.RuntimeException: Failed! HTTP Error Code: 404
at in.sblog.rest.test.RestTest.main(RestTest.java:33)





here booksConn.getResponseCode() method giving 404.

This is my Server Log




Exception.png
[Thumbnail for Exception.png]
Jar's and classes information
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are getting error code 404 so it is a problem related to the URL or resource not found. Please follow everything carefully including the project name and look how the URL pattern is formed. If you change the project name then you have to form the URL accordingly.
 
Roopesh Rana
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Anindya Roy, URL was wrong. Now It is working fine
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!