Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Problems with embedded jetty, eclipse and jersey 1.18



I have created an eclipse plugin which uses the org.eclipse.ui to start an eclipse platform with an additional menu from where I can start an embedded jetty server. The plugin is run as an “Eclipse Application”. So far so good. I have no problems running the server and accessing data from the new eclipse platform workspace (which is the whole idea of this plugin).


I’m using:

Jetty 9.2.0.RC0




Now I want to create a RESTful web service using my embedded jetty server. I decided to use the Jersey framework selecting Jersey-bundle-1.18 and javax.server-api-3.1.0.


This is my embedded jetty server:


package org.eclipse.eatop.jetty.helloworld.handlers;







import org.eclipse.core.commands.AbstractHandler;

import org.eclipse.core.commands.ExecutionEvent;

import org.eclipse.core.commands.ExecutionException;

import org.eclipse.jetty.server.Server;

import org.eclipse.jetty.servlet.ServletContextHandler;

import org.eclipse.jetty.servlet.ServletHolder;


import com.sun.jersey.spi.container.servlet.ServletContainer;

public class HelloWorldHandler extends AbstractHandler {

                             public HelloWorldHandler() {




                             * the command has been executed, so extract extract the needed information

                             * from the application context.


                             public Object execute(ExecutionEvent event) throws ExecutionException {


                             ServletHolder sh = new ServletHolder(ServletContainer.class);            

                              sh.setInitParameter("", "com.sun.jersey.api.core.PackagesResourceConfig");        

                              sh.setInitParameter("", "");//Set the package where the services reside        

                                  sh.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");               

                                  Server server = new Server(8080);        

                                  ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);

                                  context.addServlet(sh, "/*");        

                                                           try {



                                                          } catch (Exception e) {

                                                                                                                    System.out.println("Unable to start jetty web server");

                                                                                                                                                 // TODO Auto-generated catch block




                             return null;



This is my root resource package:











public class XMLProjectService {



                               public String getProject()


                                                            return "hello world" ;    





This happens when I try to access my restful web service using an IE browser:

Sep 05, 2014 1:55:22 PM com.sun.jersey.api.core.PackagesResourceConfig init

INFO: Scanning for root resource and provider classes in the packages:

Sep 05, 2014 1:55:24 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate

INFO: Initiating Jersey application, version 'Jersey: 1.18 11/22/2013 03:05 AM'

Sep 05, 2014 1:55:24 PM com.sun.jersey.server.impl.application.RootResourceUriRules <init>

SEVERE: The ResourceConfig instance does not contain any root resource classes.

2014-09-05 13:55:24.974:WARN:/:qtp999796-43: unavailable

com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.

            at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(

            at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(

            at Source)


Now, the reason for this may one of the following two:

1)      The root resource package is incorrectly formatted (for example missing @Path annotation)

2)      The root resource package is not located where it’s supposed to be


I have come to the conclusion that it must be the second reason causing this problem. My guess is that jersey simply cannot find the designated area where my root resource classes can be found. Does this have anything to do with the fact that I’m running the web service embedded into my eclipse plugin (starting the web service from the new platform)?


How can I expose the root resource package to jersey from my embedded jetty restful web service plugin?


I have no problems running this example when I’m embedding the jetty server into a simple java application. It just doesn’t work running it from inside an eclipse application.


Best regards,



Back to the top