Writing a REST service using the jetty plugin?

Howdy folks!

I'm a newbie web dev (ie, I've got plenty java experience, mostly on low-latency apps but almost nothing on servlets etc) and I'm tasked with writing a REST API using jetty.
I found the IDEA jetty plugin and thought it nifty to use it instead of embedding the jetty server.
I've configured the jetty server in the app server tab in prefs and created a module with jersey JAX_RS. I've created a small app (the infamous 'hello world'), created an artifact and
created a run configuration. I've added the artifact to the configuration but when I try to access the rest service I get a 404. I've tried various variants of the url but to no avail.
Is this possible?
My understanding is that you should be able to use annotations exclusivly and forgo a web.xml. Is this correct?

I'm grateful for any help here.

Comment actions Permalink

hard to help without seeing the project.

Comment actions Permalink

Well, then I must do better. Prepare for a deluge of screenshots!

Here is the source:

package se.phlogiston.ib;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

*         Date: 2014-06-15
*         Time: 17:09
public class HelloWorld {
    // The Java method will process HTTP GET requests
    // The Java method will produce content identified by the MIME Media type "text/plain"
    public String getClichedMessage() {
        // Return some cliched textual content
        return "Hello World!!!!";



Screen Shot 2014-06-15 at 17.19.54.png


Screen Shot 2014-06-15 at 21.18.15.png
Jersey lib:

Screen Shot 2014-06-15 at 17.20.41.png

Run configuration:

Screen Shot 2014-06-15 at 17.20.59.png

Deployment for the run conf:

Screen Shot 2014-06-15 at 17.21.15.png

Hopefully this is a step in the right direction?

Still grateful for any help!

Comment actions Permalink

you are missing web.xml, or annotated servlet.

Try this, https://github.com/jasonray/jersey-starterkit
It works fine.

Comment actions Permalink

Ok, I got it to work now. What was missing (apart from the entire web.xml :-)) was the stanza :


Once that got added it just worked, as hoped for.

Surfing around a bit I found the '@ApplicationPath' annotation that replaced the web.xml with :

public class Application extends ResourceConfig {

    public Application() {

Far easier, IMHO.

Message was edited by: Erik Svensson added part about ApplicationPath


Please sign in to leave a comment.