Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Declarative service in jetty 7.2.2

Hi!

From the message it seems you don't have a context handler collection configured in your jetty.xml.

You might want to try adding something like this to jetty.xml:

    <Set name="handler">
        <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
                <Array type="org.eclipse.jetty.server.Handler">
                    <Item>
                        <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection" />
                    </Item>
                    <Item>
                        <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler" />
                    </Item>
                </Array>
            </Set>
        </New>
    </Set>

In fact, if you start with one of the example configs you should have something similar already. You can find some at http://dev.eclipse.org/viewsvn/viewvc.cgi/jetty/trunk/jetty-server/src/main/config/etc/?root=RT_JETTY , but we used http://dev.eclipse.org/viewsvn/viewvc.cgi/jetty/trunk/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty-osgi-default.xml?view=markup&root=RT_JETTY as a starting-point.

As a first step I would recommend you to use the jetty-osgi-default.xml. Just rename it to jetty.xml and try it out. If that works it's easy to customize it from there.

If you look at http://wiki.eclipse.org/Jetty/Reference/jetty.xml you get some recommendations on what should be in there. I actually think I'll update the blog with a mention of that...

// Henrik

On Feb 17, 2011, at 14:21 , Mitul Adhia wrote:

> Hi Henrik,
> 
> As mentioned in blog http://blog.fnord.se/journal/2011/2/16/starting-and-configuring-a-jetty-7-instance-in-equinox.html i created fragmented project named jettyconfig which is called by osgi.boot bundle. Also added jetty.xml in etc folder . While debugging i could notice that the given fragmenter is called but later i found the following exception trace .....
> 
> Attached are the projects which i created .
> 
> jettyetc=etc/jetty.xml
> 2011-02-17 18:09:10.315:INFO::Configuring the default jetty server with bundleentry://68.fwk25567987/etc/jetty.xml
> java.lang.IllegalStateException: ERROR: No ContextHandlerCollection or OSGiAppProvider configured
> 	at org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper.init(ServerInstanceWrapper.java:333)
> 	at org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper.start(ServerInstanceWrapper.java:159)
> 	at org.eclipse.jetty.osgi.boot.internal.serverfactory.JettyServerServiceTracker.serviceChanged(JettyServerServiceTracker.java:108)
> 	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:104)
> 	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:933)
> 	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
> 	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:149)
> 	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:756)
> 	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:711)
> 	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
> 	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:206)
> 	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:507)
> 	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:525)
> 	at org.eclipse.jetty.osgi.boot.internal.serverfactory.DefaultJettyAtJettyHomeHelper.startJettyAtJettyHome(DefaultJettyAtJettyHomeHelper.java:152)
> 	at org.eclipse.jetty.osgi.boot.JettyBootstrapActivator.start(JettyBootstrapActivator.java:110)
> 	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774)
> 	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755)
> 	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370)
> 	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:374)
> 	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1067)
> 	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:561)
> 	at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:546)
> 	at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:459)
> 	at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
> 	at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:440)
> 	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
> 	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
> 
> The project test1.zip is the one which you have mentioned in blog how to register servlet using the Declarative approach . 
> 
> My Questions :
> 1) The data which i entered in jetty.xml (in jettyconfig.zip) consist of only information about on which server port the server would start .
> 2) I assume the following flow would happen .Just correct me if i am wrong in this .
>        a) jetty.boot bundle would start .
>        b) internally it would start jettyconfig bundle which in turn would start server on port defined in jetty.xml declared in etc/ folder of jettyconfig project.
>        c) Later it would call the test1 bundle to register the servlet dynamically .
>        d) Server is up and running with registered servlet.
> 3) Can you please check what went wrong in the project ?
> 
> Best Regards,
> mitul
> 
> 
> 
> 
> Best Regards,
> Mitul
> 
> On Wed, Feb 16, 2011 at 10:39 PM, Hugues Malphettes <hmalphettes@xxxxxxxxxxx> wrote:
> Thanks Henrik for blogging about your approach.
> It looks good to me.
> Regarding the configuration of jetty, I apologize for the lack of
> updates of the eclipse wiki and indeed your blog is the most
> exhaustive source so far.
> To start and configure jetty I usually define the system property on
> the command-line: -Djetty.home=a/path/to/jettyhome or
> -Djetty.home.bundle=symbolic.name.of.bundle.with.a.jetty.config
> 
> The reason why we don't configure the jetty.osgi.boot bundle to
> configure and start a jettty server is that projects should be in
> control of when they want to start jetty.
> 
> I use p2 from PDE's target platform or directly p2-director on the
> command-line to assemble the jetty-osgi distributions so I don't
> usually need to worry about the exact set of jetty jars to download.
> If you manually put together the jetty jars, maybe the jetty-server
> aggregate will suit your need:
> Here are the jetty dependencies that are placed in that one:
> http://repo2.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all-server/7.3.0.v20110203/jetty-all-server-7.3.0.v20110203.pom
> 
> I must say that there is a critical bug in the OSGi manifest for that aggregate.
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=337337
> It is fixed in 7.3.1
> Let me know if you want me to provide a patched 7.3.0 for that aggregate.
> 
> Cheers,
> Hugues
> 
> On Wed, Feb 16, 2011 at 9:27 PM, Henrik Gustafsson
> <henrik.gustafsson@xxxxxxxx> wrote:
> >
> > On Feb 16, 2011, at 13:05 , Mitul Adhia wrote:
> >
> >> HI All,
> >>
> >> Was trying out the example which is mentioned in blog http://blog.fnord.se/journal/2011/1/26/deploying-a-servlet-in-jetty-7-using-osgi-ds.html?lastPage=true#comment11939684.
> >> This to register the servlet in Jetty 7.2.2 using declarative service approach . Had updated the blog with the technical issues which i am facing .
> >>
> >> Can anyone help me to solve the issue?. Do let me know if more inputs are required .
> >
> > I hope so :)
> >
> > You need to ensure you have started the jetty-osgi-boot bundle, and that you have a proper jetty.xml file it can find. The jetty-osgi-boot bundle is what loads the config, starts the server and starts looking for the exposed services so you don't have to start it programmatically.
> >
> > I wrote a walkthrough, but it got a bit long, so I posted a it at http://blog.fnord.se/journal/2011/2/16/starting-and-configuring-a-jetty-7-instance-in-equinox.html . It's mostly a brain-dump though, and will probably contain some bugs. It might help you get started though (improvement suggestions are welcome!).
> >
> > // Henrik
> >
> > _______________________________________________
> > jetty-users mailing list
> > jetty-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users
> 
> <jettyconfig.zip><test1.zip>_______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top