Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Question regarding Embedded Jetty and WebApp Deployment

Hi All,
 
          I am new to this list and please pardon me, if this question has been previously answered. I did a lot of googling before I decided to post.
 
         I have previously used Jetty 6.1.15 and have recently upgraded to Jetty 9.2.12 and am struggling with the webapp deployment part of it. I have jetty bundles loaded in an OSGi runtime and am trying to start Jetty with a WebAppContext added to it. My code is similar to the examples seen  at http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html#d0e19225. My code is as follows
 
        Server server = new Server(80);
       
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        context.addServlet(new ServletHolder(new HelloServlet()),"/hello");
       
        ContextHandlerCollection contexts = new ContextHandlerCollection();
               
        WebAppContext webapp = new WebAppContext();
        webapp.setResourceBase(".");
        webapp.setDescriptor("WEB-INF/web.xml");
        webapp.setContextPath("/");
        webapp.setExtractWAR(true);
        webapp.setWar("E:\\jettyTest\\webapps\\testWebApp.war");
        contexts.setHandlers(new Handler[]{context, webapp});
       
        server.setHandler(contexts);
        server.start();
 
The server starts up fine, the servlet handler is also registered fine, but my webapp Context startup always fails with the following exception
 
 2015-08-14 14:06:13.523:INFO:oejs.Server:OSGi Console: jetty-9.2.12.v20150709
2015-08-14 14:06:13.527:INFO:oejsh.ContextHandler:OSGi Console: Started o.e.j.s.ServletContextHandler@12aa6801{/,null,AVAILABLE}
2015-08-14 14:06:13.539:WARN:oejw.WebAppContext:OSGi Console: Failed startup of context o.e.j.w.WebAppContext@71922339{/,file:/E:/jettyTest/,null}{E:\jettyTest\
webapps\testWebApp.war}
java.io.FileNotFoundException: E:\jettyTest\org\eclipse\jetty\webapp\webdefault.xml (The system cannot find the path specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:146)
        at org.eclipse.jetty.util.resource.FileResource.getInputStream(FileResource.java:290)
        at org.eclipse.jetty.webapp.Descriptor.parse(Descriptor.java:54)
        at org.eclipse.jetty.webapp.WebDescriptor.parse(WebDescriptor.java:207)
        at org.eclipse.jetty.webapp.MetaData.setDefaults(MetaData.java:171)
        at org.eclipse.jetty.webapp.WebXmlConfiguration.preConfigure(WebXmlConfiguration.java:53)
        at org.eclipse.jetty.webapp.WebAppContext.preConfigure(WebAppContext.java:468)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:504)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
        at org.eclipse.jetty.server.Server.start(Server.java:387)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
        at org.eclipse.jetty.server.Server.doStart(Server.java:354)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at com.test.jettyserver.JettyServer.startServer(JettyServer.java:46)
        at com.test.jettyserver.bundle.JettyServerCmdProvider._startServer(JettyServerCmdProvider.java:20)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:150)
        at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:302)
        at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:287)
        at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:223)
        at java.lang.Thread.run(Thread.java:745)
2015-08-14 14:06:13.587:INFO:oejs.ServerConnector:OSGi Console: Started ServerConnector@6ff7a3f3{HTTP/1.1}{0.0.0.0:7629}
2015-08-14 14:06:13.589:INFO:oejs.Server:OSGi Console: Started @9224603ms
 
I believe it is looking for some kind of default descriptor. I am not sure how to get this started without a default descriptor. Is that mandatory? Am I doing something wrong. Do kindly help.
 
Thanks,
Srijith.
 

Back to the top