Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6598377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:20:20+00:00 2026-05-25T18:20:20+00:00

I want make RESTful services using embedded jetty with JAX-RS (either resteasy or jersey).

  • 0

I want make RESTful services using embedded jetty with JAX-RS (either resteasy or jersey).
I am trying to create with maven/eclipse setup.
if I try to follow http://wikis.sun.com/pages/viewpage.action?pageId=21725365 link I am not able to resolve error from ServletHolder sh = new ServletHolder(ServletContainer.class);

public class Main {

    @Path("/")
    public static class TestResource {

        @GET
        public String get() {
            return "GET";
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        ServletHolder sh = new ServletHolder(ServletContainer.class);

        /*
         * For 0.8 and later the "com.sun.ws.rest" namespace has been renamed to
         * "com.sun.jersey". For 0.7 or early use the commented out code instead
         */
        // sh.setInitParameter("com.sun.ws.rest.config.property.resourceConfigClass",
        // "com.sun.ws.rest.api.core.PackagesResourceConfig");
        // sh.setInitParameter("com.sun.ws.rest.config.property.packages",
        // "jetty");
        sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
            "com.sun.jersey.api.core.PackagesResourceConfig");
        sh.setInitParameter("com.sun.jersey.config.property.packages",
            "edu.mit.senseable.livesingapore.platform.restws");
        // sh.setInitParameter("com.sun.jersey.config.property.packages",
        // "jetty");
        Server server = new Server(9999);

        ServletContextHandler context = new ServletContextHandler(server, "/",
            ServletContextHandler.SESSIONS);
        context.addServlet(sh, "/*");
        server.start();
        server.join();
        // Client c = Client.create();
        // WebResource r = c.resource("http://localhost:9999/");
        // System.out.println(r.get(String.class));
        //
        // server.stop();
    }
}

even this is not working.
can anyone suggest me something/tutorial/example ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:20:21+00:00Added an answer on May 25, 2026 at 6:20 pm

    huh, linked page is ancient – last update 3 years ago.

    Do you really need jetty? Jersey has excellent thoroughly tested integration with Grizzly (see http://grizzly.java.net) which is also acting as Glassfish transport layer and it is possible to use it as in your example.

    See helloworld sample from Jersey workspace, com.sun.jersey.samples.helloworld.Main class starts Grizzly and “deploys” helloworld app: http://repo1.maven.org/maven2/com/sun/jersey/samples/helloworld/1.9.1/helloworld-1.9.1-project.zip .

    If you really need jetty based sample, I guess I should be able to provide it (feel free to contact me).

    EDIT:

    ok, if you really want jetty, you can have it 🙂 and looks like its fairly simple. I followed instructions from http://docs.codehaus.org/display/JETTY/Embedding+Jetty and was able to start helloworld sample:

    public static void main(String[] args) throws Exception {
        Server server = new Server(8080);
        Context root = new Context(server,"/",Context.SESSIONS);
        root.addServlet(new ServletHolder(new ServletContainer(new PackagesResourceConfig("com.sun.jersey.samples.helloworld"))), "/");
        server.start();
    }
    

    http://localhost:8080/helloworld is accessible. I used Jetty 6.1.16. Hope it helps!

    You can find more information about configuring Jersey in servlet environment in user guide, see http://jersey.java.net/nonav/documentation/latest/

    EDIT:

    dependencies.. but this is kind of hard to specify, it changed recently in jersey.. so..

    pre 1.10:

    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <version>6.1.16</version>
    </dependency>
    <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-server</artifactId>
         <version>${jersey.version}</version>
    </dependency>
    

    post 1.10:

    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <version>6.1.16</version>
    </dependency>
    <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-servlet</artifactId>
         <version>${jersey.version}</version>
    </dependency>
    

    and you need this maven repo for jetty:

    <repositories>
        <repository>
            <id>codehaus-release-repo</id>
            <name>Codehaus Release Repo</name>
            <url>http://repository.codehaus.org</url>
        </repository>
    </repositories>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make use of RESTlet RESTful web-services. The architechture will make use
I want to make Restful - Web Service using netbean 6.5, glassfish V 2
I am a newbie in this area, I am using embedded jetty to create
I want make datetimepicker in my project. Using jquery how it is possible? I
I am traversing a HTML document using javascript DOM. I want make a list
I want to make Restful API for current PHP application with mongodb backend database.
We are developing a restful api using jersey (1.9.1) and tomcat 5.5. A given
I have a RESTful resource map.resources :books and I want to make the edit
I want to implement a RESTful webservice for an Android App using JSON. Do
I'm trying to consume a RESTful web service using WCF. I have no control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.