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?
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 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.
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.
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:
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.