aspose file tools*
The moose likes Web Services and the fly likes Who's using Jersey for JAX-RS (JSR-311)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Who Watch "Who New topic
Author

Who's using Jersey for JAX-RS (JSR-311)?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Just so we can band together and know whose brains we can try to pick (or even cry in our beer together), let's have a show of hands of people using the Jersey Project to set up a RESTful web services API that's JAX-RS (JSR-311) compliant.

Me, obviously (or I wouldn't be asking). Ulf? William?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Not yet, but I intend to in the not-too-distant future. So far I've hunted down all the required jar files (no mean feat for anyone not using Maven, since there's not yet anything resembling a decent binary distribution).

I found this blog entry useful, as well as this and this tech tip.


Ping & DNS - updated with new look and Ping home screen widget
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

I've got an instance with some simple operations up and running under Tomcat. Once you get things set up, it seems to work as expected.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12676
    
    5
I experimented with Jersey for this article and I am subscribed to the users mailing list. It looks like Jersey is progressing very nicely and the problems and new ideas get handled quickly.

Unfortunately, the NetBeans "Restful web services" plugin does not seem to have caught up with the Jersey 1.0 release - how annoying.

Bill


Java Resources at www.wbrogden.com
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
I just created a few simple services, and the API is indeed very easy to work with. In very little time I was able to create a service, add an URL parameter, constrain that by a regexp, and obtain information about the request through @Context. So I'm very pleased about it.
Faraz Ali
Ranch Hand

Joined: May 15, 2008
Posts: 108
Hi Ulf,

I am having problem in running Jersy samples with GlassFish on my eclipse IDE. Can you email me your code please? at farazali.faraz@gmail.com
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
My code is entirely based on the blog entry I linked to - be sure to read the user comments, though.

Jersey also has the "helloworld-webapp" sample code that shows much the same.

I got some further ideas that go beyond the basics from http://wikis.sun.com/display/Jersey/Overview+of+JAX-RS+1.0+Features
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Originally posted by Faraz Ali:
I am having problem in running Jersey samples with GlassFish on my eclipse IDE. Can you email me your code please?


UseTheForumNotEmail

Originally posted by Ulf Dittmer:
My code is entirely based on the blog entry I linked to - be sure to read the user comments, though.


Faraz,

All these high-powered integrated development environments are wonderful when they work - but when they fail you have to an expert on almost everything to diagnose matters quickly and effectively. Furthermore it takes them some time to catch up with "bleeding edge" technologies (in this case Jersey, REST web services have been talked about since 2002). In these cases it usually is simpler to drop down to brute force, command line and text editor. In this case I got the blog sample running with Jersey 1.0
  • by using Java version 1.6.0_07
  • using a working instance of Tomcat 6.0.16
  • creating a "helloworldrest" directory under tomcat's "webapps" folder
  • creating the "webapps/helloworldrest/WEB-INF" directory
  • creating the "webapps/helloworldrest/WEB-INF/classes" directory
  • creating the "webapps/helloworldrest/WEB-INF/lib" directory
  • copying jersey-bundle.jar, jsr311-api.jar, asm.jar from https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0/jersey/dependencies.html into the "webapps/helloworldrest/WEB-INF/lib" directory


  • Creating the "webapps/helloworldrest/WEB-INF/web.xml" file:


    Modifying the blog code (webapps/helloworldrest/WEB-INF/HelloWorldResource.java) to match Jersey 1.0 standards:

    Note: source location is brute force - never do this in production.

    Compiling the code from "webapps/helloworldrest/WEB-INF" with:


    Finally start up Tomcat and try:
    http://localhost:8080/helloworldrest/rest/helloworld
    [ November 09, 2008: Message edited by: Peer Reynders ]

    "Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
    Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
    Faraz Ali
    Ranch Hand

    Joined: May 15, 2008
    Posts: 108
    Thank you very much. I am able to run this HelloWorld example in GlassFish. But with the BookStore example, i am getting the below error on browswer:


    I modofied the getItems() method as below:


    My web.xml is:


    Annotation declaration for my BookStore class is:


    And i am invoking the service with the URL below:
    http://localhost:8080/TestJAXWS/jersey/bookstore/items/1/


    Anything wrong?
    Peer Reynders
    Bartender

    Joined: Aug 19, 2005
    Posts: 2906
    The bookstore example seems to work fine as is. Here is what I did:
  • using Java version 1.6.0_07
  • already had maven 2.0.9 installed
  • installed Glassfish V3 prelude b28c (as part of NetBeans 6.5 RC2)
  • installed Jersey 1.0-03 on Glassfish using the (command line) glassfish update tool (as described in RESTfulWeb Services Developer'sGuide)
  • using command line changed the working directory to %as_home%/jersey/samples/bookstore
  • made sure that glassfish wasn't running at the time because maven was about to run it itself
  • ran "mvn glassfish:run" - let everything happen ignoring the "SEVERE: webModuleContextConfig.missingRealm" but waited until I saw "Hit ENTER for redeploy" (i.e. don't terminate the maven process - it's running glassfish)
  • then entered the requisite URIs into the browser's URL address field.


  • Both

    http://localhost:8080/Bookstore/
    http://localhost:8080/Bookstore/items/1/

    work fine and without a hitch without any modifications.
    (And again no high-powered graphical integrated development environment - though plenty of maven2 magic)

    What exactly are you trying to achieve with your modifications?
    Peer Reynders
    Bartender

    Joined: Aug 19, 2005
    Posts: 2906
    Originally posted by Bear Bibeault:
    to set up a RESTful web services API


    For the design portion of your RESTful HTTP web service RESTful Web Services Development Checklist (PDF) (IEEE Internet Computing November/December 2008 (vol. 12 no. 6) pp. 96, 94-95) may be of interest.

    There is a whole slew of relevant columns by Steve Vinoski which can be found at Steve Vinoski's Blog: Internet Computing Columns.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Who's using Jersey for JAX-RS (JSR-311)?
     
    Similar Threads
    Help required: Compiling/Deploying a RESTful web service
    How to build RESTful Web services in Java
    Confusion about JAX-RS annotations
    java and restlet
    Accessing HttpServletRequest from Restful webservice