• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with JERSEY and JAX-RS

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try mapping the servlet to "/demo/*" instead of "/demo".
 
Farhan Raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may help: http://www.benmccann.com/dev-blog/hibernate-asm-incompatibilities/
 
Farhan Raja
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic