permaculture playing cards*
The moose likes Web Services and the fly likes Problem with JERSEY and JAX-RS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Problem with JERSEY and JAX-RS" Watch "Problem with JERSEY and JAX-RS" New topic
Author

Problem with JERSEY and JAX-RS

Farhan Raja
Greenhorn

Joined: Jun 09, 2009
Posts: 5
I am new to RESTful Services.

I am trying to deploy a simplest REST service using jersey, and JAX-RS, but i am getting this error,

HTTP ERROR: 404

NOT_FOUND

RequestURI=/hosting/demo/example

Powered by Jetty://


Where i think i have done everything right, below is the code i am using for it.

POM.XML (only pasting the part related to jersey)



WEB.XML



[b]My Class having @GET[/b]



The url i hit is: http://localhost/hosting/demo/example

Please help, its very urgent, thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41107
    
  45
Try mapping the servlet to "/demo/*" instead of "/demo".


Ping & DNS - my free Android networking tools app
Farhan Raja
Greenhorn

Joined: Jun 09, 2009
Posts: 5
I have also tried /demo/* but this gives me an exception and i am unable to figure out the reason for that as well,

the stack trae is

HTTP ERROR: 500

org.objectweb.asm.ClassReader.accept(Lorg/objectweb/asm/ClassVisitor;I)V

RequestURI=/hosting/demo/example
Caused by:

java.lang.NoSuchMethodError: org.objectweb.asm.ClassReader.accept(Lorg/objectweb/asm/ClassVisitor;I)V
at com.sun.jersey.server.impl.container.config.AnnotatedClassScanner.analyzeClassFile(AnnotatedClassScanner.java:263)
at com.sun.jersey.server.impl.container.config.AnnotatedClassScanner.indexDir(AnnotatedClassScanner.java:212)
at com.sun.jersey.server.impl.container.config.AnnotatedClassScanner.index(AnnotatedClassScanner.java:185)
at com.sun.jersey.server.impl.container.config.AnnotatedClassScanner.scan(AnnotatedClassScanner.java:129)
at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:114)
at com.sun.jersey.api.core.PackagesResourceConfig.(PackagesResourceConfig.java:78)
at com.sun.jersey.api.core.PackagesResourceConfig.(PackagesResourceConfig.java:89)
at com.sun.jersey.spi.container.servlet.ServletContainer.createResourceConfig(ServletContainer.java:403)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:204)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:400)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:346)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:422)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:356)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:226)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:627)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:149)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:123)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:141)
at org.mortbay.jetty.Server.handle(Server.java:269)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:430)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:687)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:492)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:199)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:339)
at org.mortbay.jetty.nio.HttpChannelEndPoint.run(HttpChannelEndPoint.java:270)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:475)

Powered by Jetty://
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41107
    
  45
Sounds like the version of Jersey you're using and the version of ASM don't go together. Are you using ASM 3.1? Or maybe Jetty uses ASM internally, and there's a version mismatch?
Farhan Raja
Greenhorn

Joined: Jun 09, 2009
Posts: 5
I am working in an existing established project, and it is using ASM 1.5.3,

now how can i force jetty/maven to use ASM 3.1, as if i just put ASM 3.1 in repository, then hibernate starts giving exceptions,

so can you please guide me that how can i force in POM.xml(or whatever), to use ASM 3.1 ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41107
    
  45
This may help: http://www.benmccann.com/dev-blog/hibernate-asm-incompatibilities/
Farhan Raja
Greenhorn

Joined: Jun 09, 2009
Posts: 5
Thanks for the help, but my problem still persists, after digging in to the issue more, i have found out that

hibernate and JAX-RS reference implementations cannot work together, as hibernate requires ASM 2.2.3 and JAX-RS requires 3.1, this is present on the URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-358

It seems that this problem is not fixed. Do you know any workaround for this ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41107
    
  45
So you've tried using the cglib-nodep library and it doesn't work?

The bug report you linked to mentions two more ways around this, in the first and the last post by J├╝rgen Zimmermann. Have you tried both, and found that neither works?
Farhan Raja
Greenhorn

Joined: Jun 09, 2009
Posts: 5
Yeah i have tried these options,

1. i used cglib 2.2, but no help
2. i also used cglib-nodep, but no help
3. I also put javassist in dependencies but my project is using hibernate.cfg.xml file, and javassist can only be configured in hibernate.properties file, not in XML.

So no solutions seems to work for me
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with JERSEY and JAX-RS
 
Similar Threads
Strange problem - works on maven glassfish but not on Tomcat
JSF 2 - Problem with ManagedBean
Funny exception with StringBuffer with jsf
Maven web project dependencies
How to change jetty binding port number in maven.