Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64712
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
     
    Faraz Ali
    Ranch Hand
    Posts: 108
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 2968
    6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic