users@jersey.java.net

embedding jersey inside GrizzlyWebServer

From: Zoltan Arnold NAGY <Zoltan.Nagy_at_Sun.COM>
Date: Tue, 28 Apr 2009 08:25:34 +0200

hey there,

I'm trying to do the thing in the $subject. This is what I have so far:

        GrizzlyWebServer ws = new GrizzlyWebServer(7000);
        ServletAdapter jerseyAdapter = new ServletAdapter();
        jerseyAdapter.setServletInstance(new
com.sun.jersey.spi.container.servlet.ServletContainer());
        jerseyAdapter.setProperty("javax.ws.rs.Application",
"org.antares.rs.JerseyAdaptor");
        ws.addGrizzlyAdapter(jerseyAdapter, new String[] { "/jersey" });

JerseyAdaptor looks like:

public class JerseyAdaptor extends Application {
    @Override
    public Set<Class<?>> getClasses() {
        Set<Class<?>> classes = new HashSet<Class<?>>();

        classes.add(org.antares.rs.HelloResource.class);
        return classes;
    }
}

and HelloResource is just your basic hello world resource :)

however, it's not working. when I try to access it this is what I get:
Apr 28, 2009 1:14:15 AM com.sun.jersey.api.core.ClasspathResourceConfig init
INFO: Scanning for root resource and provider classes in the paths:
  C:\Users\Zoltan Arnold
NAGY\Documents\NetBeansProjects\antares~source-code-repository\antares\WEB-INF\lib
  C:\Users\Zoltan Arnold
NAGY\Documents\NetBeansProjects\antares~source-code-repository\antares\WEB-INF\classes
Apr 28, 2009 1:14:15 AM
com.sun.jersey.server.impl.container.config.AnnotatedClassScanner index
WARNING: File, C:\Users\Zoltan Arnold
NAGY\Documents\NetBeansProjects\antares~source-code-repository\antares\WEB-INF\lib,
is ignored, it not a directory, a jar file or a zip file
Apr 28, 2009 1:14:15 AM
com.sun.jersey.server.impl.container.config.AnnotatedClassScanner index
WARNING: File, C:\Users\Zoltan Arnold
NAGY\Documents\NetBeansProjects\antares~source-code-repository\antares\WEB-INF\classes,
is ignored, it not a directory, a jar file or a zip file
Apr 28, 2009 1:14:18 AM
com.sun.jersey.server.impl.application.WebApplicationImpl
processRootResources
SEVERE: The ResourceConfig instance does not contain any root resource
classes.
Apr 28, 2009 1:14:18 AM com.sun.grizzly.http.servlet.ServletAdapter service
SEVERE: service exception:
com.sun.jersey.api.container.ContainerException: The ResourceConfig
instance does not contain any root resource classes.

well I don't want to run it from a war, that's why I wrote
JerseyAdaptor. I'd like to embed it, specifying the resources I'd like
to use, and nothing more. So no WEB-INF, no directory, nothing. Just
embedded use :-)

What's the least painful way to achieve this?

Thanks!

Zoltan