dev@jersey.java.net

OSGi/Grizzly/HttpsService support<was>Re: [Jersey] OSGi Support

From: Jakub Podlesak <Jakub.Podlesak_at_Sun.COM>
Date: Tue, 26 Jan 2010 18:08:09 +0100

On Tue, Jan 26, 2010 at 09:08:58AM -0500, David Tkaczyk wrote:
> OK Paul. thank you. do you have an ETA for the next release? And what will
> it be, 1.1.6? Any hints from Jakub would be greatly appreciated.

Hi David, i am going to add one more test to the trunk using the HttpService scenario
based on your previous e-mail (just after commiting an OSGified WAR deployment
test, which i have ready locally), as that would be the best way to ensure
the (HttpService) scenario works fine and also to show how to configure things.
I expect to have more information on that for you tomorow.

~Jakub

>
>
>
> _____
>
> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
> Sent: Tuesday, January 26, 2010 5:02 AM
> To: dev_at_jersey.dev.java.net
> Subject: Re: [Jersey] OSGi Support
>
>
>
> Hi David,
>
>
>
> We decided to defer OSGi to the next release (which will occur when OSGi
> support is ready). We were not happy with the degree of testing.
>
>
>
> For now you need to check out the Jersey trunk
>
>
>
> svn checkout https://jersey.dev.java.net/svn/jersey/trunk/jersey jersey
> --username username
>
>
>
> and do:
>
>
>
> cd osgi
>
> mvn clean install
>
>
>
> and then use those built OSGi specific maven artifacts.
>
>
>
> Jakub can provide further details, especally w.r.t. your code.
>
>
>
> Paul.
>
>
>
> On Jan 25, 2010, at 7:59 PM, David Tkaczyk wrote:
>
>
>
>
>
> Hi Paul,
>
>
>
> I had hoped that 1.1.5 would fix my issues with felix/grizzly/jersey. I am
> still unable to get grizzly to load my jersey servlet properly. I've tried
> a bunch of different things with no luck. I see a test case that uses
> embedded grizzly, but none that actually use HttpService. The Grizzly test
> cases use the Jersey client, but do not create a Jersey Servlet. I have
> posted on Grizzly as well with no luck yet.
>
>
>
> I am able to successfully get an HttpService object from Felix and the
> Grizzly bundle. My trouble happens when trying to register a Jersey Servlet
> with this HttpService object. I'll post my code and the error message
> below. There's not much to it, but I can't get it to work.
>
>
>
> Can you please have your OSGi guy see if he can get this to work? There's
> got to be something small I'm missing. I am getting very desperate to get
> this to finally hitch up.
>
>
>
> Thanks for all your help past and present,
>
> Dave
>
>
>
> package camiant.osgi.msr.rest;
>
>
>
> 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.spi.container.servlet.ServletContainer;
>
>
>
> public class RestGrizzlyServiceTrackerCustomizer implements
> ServiceTrackerCustomizer {
>
>
>
> private static final Logger LOGGER =
> LoggerFactory.getLogger(RestGrizzlyServiceTrackerCustomizer.class);
>
> private HttpService grizzlyService = null;
>
>
>
> @Override
>
> public Object addingService(ServiceReference serviceRef) {
>
> LOGGER.info("Adding service: " +
> serviceRef.getBundle().getSymbolicName());
>
>
>
> grizzlyService =
> (HttpService)serviceRef.getBundle().getBundleContext().getService(serviceRef
> );
>
> try {
>
> ServletContainer jerseyServletContainer = new ServletContainer(new
> MSRRestApplication());
>
> grizzlyService.registerServlet("/rs", jerseyServletContainer, null,
> null);
>
> } catch (Exception e) {
>
> e.printStackTrace();
>
> grizzlyService = null;
>
> }
>
>
>
> return grizzlyService;
>
> }
>
>
>
> @Override
>
> public void modifiedService(ServiceReference serviceRef, Object
> httpService) {
>
> LOGGER.info("Modifying service: " +
> serviceRef.getBundle().getSymbolicName());
>
> removedService(serviceRef, httpService);
>
> addingService(serviceRef);
>
> }
>
>
>
> @Override
>
> public void removedService(ServiceReference serviceRef, Object
> httpService) {
>
> LOGGER.info("Removing service: " +
> serviceRef.getBundle().getSymbolicName());
>
> ((HttpService)httpService).unregister("/rs");
>
> serviceRef.getBundle().getBundleContext().ungetService(serviceRef);
>
> httpService = null;
>
> }
>
> }
>
>
>
> package camiant.osgi.msr.rest;
>
>
>
> import java.util.Collections;
>
> import java.util.Set;
>
> import javax.ws.rs.ApplicationPath;
>
> import javax.ws.rs.core.Application;
>
> import camiant.osgi.msr.rest.resource.Resource1;
>
>
>
> @ApplicationPath("/rs")
>
> public class MSRRestApplication extends Application {
>
> @Override
>
> public Set<Class<?>> getClasses() {
>
> return Collections.<Class<?>>singleton(Resource1.class);
>
> }
>
> }
>
>
>
> package camiant.osgi.msr.rest.resource;
>
>
>
> import javax.ws.rs.GET;
>
> import javax.ws.rs.Path;
>
> import javax.ws.rs.Produces;
>
>
>
> @Path("/msr")
>
> public class Resource1 {
>
> @GET
>
> @Path("/keytypes")
>
> @Produces("text/plain")
>
> public String getKeyTypes() {
>
> return "this is a key type!!!!!!!!!";
>
> }
>
> }
>
>
>
> 2010-01-25 13:54:37,675-0500 INFO RestGrizzlyServiceTrackerCustomizer:19 -
> Adding service: com.sun.grizzly.osgi.grizzly-httpservice-bundle
>
> 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.RestGrizzlyServiceTrackerCustomizer.addingService(Rest
> GrizzlyServiceTrackerCustomizer.java:24)
>
> 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
>
> ->
>
>
>
> _____
>
> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
> Sent: Tuesday, January 05, 2010 4:11 AM
> To: dev_at_jersey.dev.java.net
> Subject: Re: [Jersey] OSGi Support
>
>
>
>
>
> On Jan 4, 2010, at 7:02 PM, David Tkaczyk wrote:
>
>
>
>
>
>
> Thanks Paul -
>
>
>
> I read your response. I'd be happy to do a bit of testing when 1.5.1 is
> ready for beta/release/candidate/whatever. My environment is
> Felix/Grizzly/Jersey.
>
>
>
>
>
> Great. We will make an announcement when Jakub has something available in
> the trunk and SNAPSHOT builds.
>
>
>
> Paul.
>
>
>
>
>
> Dave
>
>
>
>
> _____
>
>
> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
> Sent: Tuesday, December 29, 2009 5:31 AM
> To: dev_at_jersey.dev.java.net
> Subject: Re: [Jersey] OSGi Support
>
>
>
> Hi David,
>
>
>
> I will reply fully to your email on the users list.
>
>
>
> Paul.
>
>
>
> On Dec 28, 2009, at 9:03 PM, David Tkaczyk wrote:
>
>
>
>
>
>
>
>
>
> Hi,
>
>
>
> I understand that Jersey 1.1.5 will support OSGi. Is there an estimated
> delivery date for this version? In the meantime, does anyone have an
> example using Felix/HttpService? I have tried 1.1.5 ea and 1.1.4.1 and it
> won't find my resource class no matter what I try. There are a few
> seemingly outdated examples on the web that I could not get working either.
> I keep telling myself I can't be the only one with this problem. Or should
> I just be patient and wait for the official release?
>
>
>
> I have posted a similar question on the "users" mailing list as well.
>
>
>
> Thanks,
> Dave
>
>
>
> David Tkaczyk
>
> Member of Technical Staff
>
> Office: 508-303-4162
>
> Fax: 508-486-9595
>
>
>
>
> <http://www.fiercewireless.com/special-reports/camiant-top-wireless-company-
> 2009-fiercewireless-fierce-15> <image001.gif>
>
>
>
> <http://www.camiant.com> www.camiant.com
>
> 200 Nickerson Road, Marlborough, MA 01752-4603 USA
>
>
>
> <http://twitter.com/camiant> <image002.gif>
>
>
>
>
>
>
>
>
>

-- 
http://blogs.sun.com/japod