• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with Jersey framework  RSS feed

 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Eclipse to develop a Jersey web service (jersey-bundle-1.12.jar). My web.xml is:

My controller class is:


On "http://02190-pc.infinityit.local:8080/JerseyWebService/jersey" I get the message "The webpage cannot be found". Strangely, "http://02190-pc.infinityit.local:8080/JerseyWebService/jersey/jersey" reponds but with an empty page.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On "http://02190-pc.infinityit.local:8080/JerseyWebService/jersey" I get the message "The webpage cannot be found".

That is to be expected, since nothing is configured at that address. The servlet listens to "/jersey", and then this controller is listening for "/jersey" - so all service URLs for it are ".../jersey/jersey/..."

Is the getList method being called?
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your prompt reply. Well, I am a newbie; actually the get method method was not being called; now I think it was because I was missing @Produces. Unfortunately, I started changing jars and now I am getting exceptions (I have asm-4.0.jar, jersey-bundle-1.12.jar and jsr311-api-1.1.1.jar in the lib folder under WEB-INFO). starting Tomcat I am getting "java.lang.IncompatibleClassChangeError (horror a classloader problem): Implementing class". Yes, I should have kept I copy of what was working without exception before.
I have studied Jersey and I understand it quite well; its relatively simple. I thought all I had to do was to create a dynamic web project, put the appropriate jars in the lib folder and code the controller class with annotations. I've been struggling for four days. I you could give me some orientation, I would appreciate it.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"dynamic web project" sounds like something an IDE would have. For deployment purposes I advise to ignore the IDE, and deploy in a standalone servlet container. All libraries would go into the web app's WEB-INF/lib directory.

Note that getList has no @Path annotation - you may wish to add that.

Jersey 1.12 is quite old, I don't recall with which libraries it came. My current version uses activation-1.1.1.jar, asm-3.1.jar, jackson-core-asl-1.9.2.jar, jaxb-api-2.2.4.jar, jaxb-impl-2.2.4-1.jar, jersey-core-1.17.1.jar, jersey-json-1.17.1.jar, jersey-server-1.17.1.jar, jersey-servlet-1.17.1.jar, json_simple-1.1.jar, jsr311-api-1.1.1.jar and some Apache Commons libraries. Not all these are required for basic use, though. You may be best advised to grab a fresh copy of all libraries form the Jersey site, maybe upgrading to 1.17.1 (the latest JAX-RS 1.x version) in the process.
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again. If I create a war file and set it in Tomcat I still get the same problem; you are correct, I should be working with Jersey 2.x. On the other hand, I am having another problem working with the Jersey 2.x jars in folder jaxrs-ri (I put all the jars in the lib folder), but when I start tomcat I get the exception "java.lang.NoSuchMethodError: org.glassfish.hk2.utilities.AbstractActiveDescriptor.<init>(Ljava/util/Set;Ljava/lang/Class;Ljava/lang/String;Ljava/util/Set;Lorg/glassfish/hk2/api/DescriptorType;Lorg/glassfish/hk2/api/DescriptorVisibility;ILjava/lang/Boolean;Ljava/lang/Boolean;Ljava/lang/String;Ljava/util/Map;)V". The class is there, but it appears it is expecting a different constructor. Just a few links in the internet, but no solution.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jersey 2 implements JAX-RS 2, which builds on top of JEE 7 - and that in turn requires a Servlet 3.1 container like Tomcat 8; is that what you're using? Given that Tomcat 8 isn't even final yet , I'd stay away from it, and thus also from Jersey 2.
 
Alejandro Barrero
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. I turned to NetBeans and it is trivial; no jar files, no web.xml, just coding with annotations.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!