>
>
>         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(".");
>

Don't use this with a webapp (the .setWar() a few lines below this does
this for you, and correctly)


>         webapp.setDescriptor("WEB-INF/web.xml");
>         webapp.setContextPath("/");
>

This is the same contextPath as your ServletContextHandler above, this will
never work, as your ServletContextHandler will answer all requests, never
letting your WebAppContext process anything.

Just skip the ServletContextHandler entirely.
Use webapp.addServlet() instead.


>         webapp.setExtractWAR(true);
>         webapp.setWar("E:\\jettyTest\\webapps\\testWebApp.war");
>         contexts.setHandlers(new Handler[]{context, webapp});
>

If you have no ServletContextHandler, then you don't need the
ContextHandlerCollection.


>
>         server.setHandler(contexts);
>

If you have no ContextHandlerCollection, you can just use
server.setHandler(webapp)


>         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
>

Jetty 9.2.13.v20150730 is the current stable version of Jetty 9.2.x


> 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)
>

The change to not use .setResourceBase() should have made an improvement
here.

- Joakim
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to