You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by David Tkaczyk <dj...@comcast.net> on 2009/12/23 22:45:45 UTC
Felix/Grizzly/Jersey
Hi,
I'm really struggling (going on 2 or 3 days now) to get Felix to work with a
Grizzly http service deploying a Jersey servlet. I've googled like crazy to
try and resolve on my own, but no luck. I'm hoping that I'm overlooking
something simple that someone can point out to me. Everything is
ACTIVE/RESOLVED from an osgi perspective. My problem appears to be that
Jersey cannot locate my resource file. Along with Jersey's inability to
find my resource class there's also a stack trace
(ServiceConfigurationError) that I'll post below.
Thanks,
Dave
package camiant.osgi.msr.rest;
import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.jersey.server.impl.container.servlet.ServletAdaptor;
public class HttpServiceServiceTrackerCustomizer implements
ServiceTrackerCustomizer {
private static final Logger LOGGER =
LoggerFactory.getLogger(HttpServiceServiceTrackerCustomizer.class);
private static final Dictionary<String, String> JERSEY_INIT_PARAMS = new
Hashtable<String, String>();
static {
// NOTE: I've tried several different ways to get Jersey to find my
resource file, but no luck. package config/resource config/custom
Application
// Just about every different way that Jersey allows, I've
tried
JERSEY_INIT_PARAMS.put("com.sun.jersey.config.property.packages",
"camiant.osgi.msr.rest.resource");
}
@Override
public Object addingService(ServiceReference serviceRef) {
LOGGER.info("Adding service: " +
serviceRef.getBundle().getSymbolicName());
HttpService grizzlyService =
(HttpService)serviceRef.getBundle().getBundleContext().getService(serviceRef
);
try {
// NOTE: as you see I've tried both ServletContainer and
ServletAdaptor - both produce similar results
//grizzlyService.registerServlet("/rs", new ServletContainer(),
JERSEY_INIT_PARAMS, null);
grizzlyService.registerServlet("/rs", new ServletAdaptor(),
JERSEY_INIT_PARAMS, null);
} catch (Exception e) {
e.printStackTrace(); //TODO what is best here..
grizzlyService = null;
}
return grizzlyService;
}
}
package camiant.osgi.msr.rest.resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@Path("/msr")
public class TestResource {
@GET
@Path("/keytypes")
@Produces("text/xml")
public Response getKeyTypes() {
return Response.ok().entity("this is a cheap key type!!!!!!!!!").build();
}
}
Welcome to Felix
================
2009-12-23 16:30:47,872-0500 INFO RestMSRCoreServiceTrackerCustomizer:16 -
Adding service: camiant.osgi.msr.core
Dec 23, 2009 4:30:48 PM com.sun.grizzly.Controller logVersion
INFO: Starting Grizzly Framework 1.9.18-e - Wed Dec 23 16:30:48 EST 2009
2009-12-23 16:30:48,220-0500 INFO HttpServiceServiceTrackerCustomizer:65 -
Adding service: com.sun.grizzly.osgi.grizzly-httpservice-bundle
Dec 23, 2009 4:30:48 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
camiant.osgi.msr.rest.resource
Dec 23, 2009 4:30:48 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No root resource classes found.
Dec 23, 2009 4:30:48 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
ERROR: EventDispatcher: Error during dispatch.
(com.sun.jersey.spi.service.ServiceConfigurationError:
com.sun.jersey.spi.container.WebApplicationProvider: The class
com.sun.jersey.server.impl.container.WebApplicationProviderImpl implementing
provider interface com.sun.jersey.spi.container.WebApplicationProvider could
not be instantiated: null)
com.sun.jersey.spi.service.ServiceConfigurationError:
com.sun.jersey.spi.container.WebApplicationProvider: The class
com.sun.jersey.server.impl.container.WebApplicationProviderImpl implementing
provider interface com.sun.jersey.spi.container.WebApplicationProvider could
not be instantiated: null
at
com.sun.jersey.spi.service.ServiceFinder.fail(ServiceFinder.java:380)
at
com.sun.jersey.spi.service.ServiceFinder.access$600(ServiceFinder.java:144)
at
com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceF
inder.java:683)
at
com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebA
pplicationFactory.java:61)
at
com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContaine
r.java:325)
at
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.c
reate(ServletContainer.java:240)
at
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:548
)
at
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:201
)
at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.
java:307)
at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.
java:470)
at javax.servlet.GenericServlet.init(GenericServlet.java:242)
at
com.sun.grizzly.http.servlet.ServletAdapter.loadServlet(ServletAdapter.java:
428)
at
com.sun.grizzly.osgi.httpservice.OSGiServletAdapter.startServlet(OSGiServlet
Adapter.java:99)
at
com.sun.grizzly.osgi.httpservice.OSGiMainAdapter.registerServletAdapter(OSGi
MainAdapter.java:178)
at
com.sun.grizzly.osgi.httpservice.HttpServiceImpl.registerServlet(HttpService
Impl.java:92)
at
camiant.osgi.msr.rest.HttpServiceServiceTrackerCustomizer.addingService(Http
ServiceServiceTrackerCustomizer.java:70)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker
.java:896)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
at
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
at
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.j
ava:840)
at
org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallbac
k(EventDispatcher.java:878)
at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDi
spatcher.java:732)
at
org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispat
cher.java:662)
at
org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3587)
at org.apache.felix.framework.Felix.access$000(Felix.java:40)
at
org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:625)
at
org.apache.felix.framework.ServiceRegistry.registerService(ServiceRegistry.j
ava:90)
at
org.apache.felix.framework.Felix.registerService(Felix.java:2711)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextIm
pl.java:252)
at
org.apache.felix.framework.BundleContextImpl.registerService(BundleContextIm
pl.java:230)
at
com.sun.grizzly.osgi.httpservice.Activator.start(Activator.java:89)
at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.jav
a:639)
at
org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
at
org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at
com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceF
inder.java:641)
... 34 more
[INFO] Started bridged http service
-> *INFO * Failed to instantiate plugin
org.apache.felix.webconsole.internal.compendium.ComponentsServlet. Reason:
java.lang.NoClassDefFoundError: org.apache.felix.scr.ScrService
*INFO * Failed to instantiate plugin
org.apache.felix.webconsole.internal.compendium.ConfigManager. Reason:
java.lang.NoClassDefFoundError:
org/osgi/service/metatype/ObjectClassDefinition
*INFO * Failed to instantiate plugin
org.apache.felix.webconsole.internal.compendium.PreferencesConfigurationPrin
ter. Reason: java.lang.NoClassDefFoundError:
org/osgi/service/prefs/BackingStoreException
*INFO * Failed to instantiate plugin
org.apache.felix.webconsole.internal.deppack.DepPackServlet. Reason:
java.lang.NoClassDefFoundError:
org/osgi/service/deploymentadmin/DeploymentException
ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (2.0.1)
[ 1] [Active ] [ 1] Ant repackaging (3.0.0.b74b)
[ 2] [Active ] [ 1] ASM all classes (3.2)
[ 3] [Active ] [ 1] Camiant MSR Core (0.1.0)
[ 4] [Active ] [ 1] Camiant MSR REST (0.1.0)
[ 5] [Active ] [ 1] Grizzly OSGi HttpService Bundle (1.9.18.e)
[ 6] [Active ] [ 1] http (0)
[ 7] [Active ] [ 1] Jackson JSON processor (1.1.1)
[ 8] [Active ] [ 1] javax.annotation API v.1.1 (3.0.0.b74b)
[ 9] [Active ] [ 1] javax.ejb API v.3.1 (3.0.0.b74b)
[ 10] [Active ] [ 1] Java Persistence API 2.0 (2.0.0.v200911271158)
[ 11] [Active ] [ 1] javax.servlet API v.3.0 (3.0.0.b74b)
[ 12] [Active ] [ 1] javax.servlet.jsp API v.2.1.2 (3.0.0.b74b)
[ 13] [Active ] [ 1] jaxb-api (2.2)
[ 14] [Active ] [ 1] jaxb (2.2)
[ 15] [Active ] [ 1] jdom (0)
[ 16] [Active ] [ 1] jersey-bundle (1.1.5.ea-SNAPSHOT)
[ 17] [Active ] [ 1] jettison (1.1)
[ 18] [Active ] [ 1] jsr311-api (1.1.1)
[ 19] [Active ] [ 1] JavaMail API (1.4.3)
[ 20] [Active ] [ 1] Apache Felix Configuration Admin Service
(1.2.4)
[ 21] [Active ] [ 1] Apache Felix Http Bundle (2.0.4)
[ 22] [Active ] [ 1] Apache Felix Shell Service (1.4.1)
[ 23] [Active ] [ 1] Apache Felix Shell TUI (1.4.1)
[ 24] [Active ] [ 1] Apache Felix Web Management Console (2.0.2)
[ 25] [Resolved ] [ 1] Camiant MSR Log4JProperties (0.5.0)
[ 26] [Active ] [ 1] Apache Jakarta log4j Plug-in
(1.2.15.v200910021404)
[ 27] [Active ] [ 1] ROME, RSS and atOM utilitiEs for Java (1.0)
[ 28] [Active ] [ 1] slf4j-api (1.5.8)
[ 29] [Resolved ] [ 1] slf4j-log4j12 (1.5.8)
[ 30] [Active ] [ 1] Sun Misc RT Packages (1.0.0)
[ 31] [Active ] [ 1] tools (0)
[ 32] [Active ] [ 1] Weld OSGi Bundle (1.0.0.SP4)
RE: Felix/Grizzly/Jersey
Posted by David Tkaczyk <dj...@comcast.net>.
Guo -
Thanks for the reply. I will try that. If you notice that message is only
at INFO and is not my core question. I still hope that someone out there
can help me configure Jersey properly.
Thanks,
Dave
-----Original Message-----
From: Guo Du [mailto:mrduguo@gmail.com]
Sent: Wednesday, December 23, 2009 7:57 PM
To: users@felix.apache.org
Subject: Re: Felix/Grizzly/Jersey
On Wed, Dec 23, 2009 at 9:45 PM, David Tkaczyk <dj...@comcast.net> wrote:
> org.apache.felix.webconsole.internal.deppack.DepPackServlet. Reason:
> java.lang.NoClassDefFoundError:
> org/osgi/service/deploymentadmin/DeploymentException
Did you install org.osgi.compendium (OSGi R4 Compendium Bundle)?
-Guo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Felix/Grizzly/Jersey
Posted by Guo Du <mr...@gmail.com>.
On Wed, Dec 23, 2009 at 9:45 PM, David Tkaczyk <dj...@comcast.net> wrote:
> org.apache.felix.webconsole.internal.deppack.DepPackServlet. Reason:
> java.lang.NoClassDefFoundError:
> org/osgi/service/deploymentadmin/DeploymentException
Did you install org.osgi.compendium (OSGi R4 Compendium Bundle)?
-Guo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org