Maven is the apt-get for jars. Descriptor-less deployment seems to make plug-n-play more easily. JAX-RS annotations make REST on Servlet platform simpler.
Alright, after several experiment failures, I figured out a way to get Jersey working on Tomcat with help from Maven and Eclipse.
So real stuff:
- Create a "Dynamic Web Project".
- Right click on the new project, "Configure" > "Convert to Maven project...".
- Add Jersey dependency to pom.xml: (this MUST be added with a "compile" scope, "provided" will fail to let Tomcat discover the REST app; for other containers/platforms, read this)
- Save pom, Maven update.
- Create a class extends
javax.ws.rs.core.Application, annotated with
- Create a class, annotated with
javax.ws.rs.Path. Individual methods of this class should be properly annotated with
javax.ws.rs.GETetc. for handling requests.