[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Using Jetty in OSGi

I do not know much about Equinox OSGi implementation but I may give
some answers based on my experience with Pax Web (also an HttpService
implementation based on Jetty):

1. In may view everything it's okay as soon as it serves you goals.
So, I would not see any problem in the fact that you implement your
own http server based on Jetty. Just be sure that you wanna do so, at
that will mean that you have to implement it, maintain it and so on,
more or less by your own, compared with an implementation that is
backed up by a community.

Looking at your "future" goals you may wanna take a look at Pax Web
Extender Web that allows you to deploy a war like bundle, by parsing
your web.xml and register found elements. To have a full support you
have to use Pax Web implementation of HttpService (because it has an
extended HttpService implementation supporting listeners/filters/...).
Just for a simple web.xml that uses only servlets/resources you can
use it with any HttpService implementation as the one available from
Equinox.
If you want a direct integration with Jetty you may wanna take a look
at Spring DM web support.

2. The problem is that you pass the class name to Jetty, and Jetty
will try to instantiate the class, fact that will fail as Jetty will
not see your bundle class space.
I do not know how Equinox implementation actually uses Jetty but in
principle you may want to pass an instance of the Servlet to Jetty not
the class name. As an example you can take a look here for how you can
do that,, and look for add servlet:
https://scm.ops4j.org/repos/ops4j/projects/pax/web/bundle/src/main/java/org/ops4j/pax/web/service/internal/JettyServerImpl.java

I suppose that Simon can give you more details about the Equinox implementation.

HTH,
Alin Dreghiciu

On Thu, May 29, 2008 at 12:22 PM, Srijith Kochunni <ksrijith@xxxxxxxxxx> wrote:
> Hi All,
>
>         I am trying to deploy Jetty server in my Equinox OSGi runtime. I was
> able to deploy the org.mortbay.jetty jar and the additional equinox jars and
> was able to register my servlet using OSGi http service and was able to view
> the same in browser. But my requirement is that I want to design so that in
> future i might be able to provide a container where web applications can be
> deployed as well. Therefore i want to directly use org.mortbay.jetty.Server
> class to add my servlets rather than HttpService.
>
>                                                 Server server = new
> Server();
>
> SocketListener listener = new SocketListener();
>
> listener.setPort(8080);
>
> server.addListener(listener);
>
> ServletHttpContext httpcontext =
> (ServletHttpContext)server.getContext("/servlet");
>
> httpcontext.addServlet("Hello", "/hello", "axisserver.HelloWorldServlet");
>
> server.start();
>
> Since I do not want the equinox http service to register and do the starting
> up of the server, I load my OSGi runtime with org.mortbay.jetty jar alone
> and start my bundle in which I have the above code snippet in the start
> method of my activator.
>
> My first question is whether it is ok for me to do this within OSGi, or
> should I always use only the HttpService interface provided my OSGi. ?
>
> The second question is
>
>     The problem is that everytime I start my bundle, it gives me a
> ClassNotFound exception and does not start. Have attached the stack trace.
> The class is within my bundle, so am not able to understand why it is not
> found. >From the stack trace understood that the mortbay bundle is probably
> trying to load the class, therefore tried exporting my package as well, but
> to no avail. Read in some of the jetty forums that these class loading
> issues can be resolved by Eclipse Buddy policy. Am not sure how to use them.
> Also read about how PDE can be helpful in deducting and fixing these class
> loading issues.
>
> Any idea on how this issue can be fixed/ details on what HttpService is
> doing extra while using Jetty Server, in order to put the classes in mortbay
> jetty server`s space would be helpful
>
> Any help in this regard, would be greatly appreciated.
>
> P.S : Have herewith attached stack trace.
>
> Thanks,
>
> Srijith.
>
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>



-- 
Alin Dreghiciu
http://www.ops4j.org - New Energy for OSS Communities - Open
Participation Software.
http://www.qi4j.org - New Energy for Java - Domain Driven Development.
http://malaysia.jayway.net - New Energy for Projects - Great People
working on Great Projects at Great Places