title: Running a web application (WAR) with embedded jetty server
body: <p>I have made a very basic web application that has only one html page. I exported it as a war.</p>
  
  <p>Now I created an embedded jetty server.</p>
  
  <pre><code>public class SimplestServer {
  
  public static void main(String[] args) throws Exception{
      Server server = new Server(8000);
  
      WebAppContext webapp = new WebAppContext();
      webapp.setContextPath("/");
      webapp.setWar("C:\\Users\\User\\Desktop\\jetty\\JettyWar.war");
      server.setHandler(webapp);
  
      server.start();
      server.join();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I created a jar for this embedded server. But when I try to run my web application through the embedded server,I get the following error.</p>
  
  <p>C:\Users\User>java -jar C:\Users\User\Desktop\jetty\webServer.jar</p>
  
  <blockquote>
    <p>C:\Users\User>java -jar C:\Users\User\Desktop\jetty\webServer.jar ..
    2014-02-18 22:43:15.400:INFO:oejs.Server:jetty-8.y.z-SNAPSHOT
    2014-02-18 22:43:15.490:INFO:oejw.WebInfConfiguration:Extract
    jar:file:/C:/Users/User/Desktop/jetty/JettyWar.war!/ to
    C:\Users\User\AppData\Loca
    \jetty-0.0.0.0-8000-JettyWar.war-<em>-any-\webapp 2014-02-18
    22:43:15.878:WARN:oejuc.AbstractLifeCycle:FAILED jsp:
    java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
    java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
            at org.apache.jasper.servlet.JspServlet.(JspServlet.java:68)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at java.lang.Class.newInstance(Unknown Source)
            at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1075)
            at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:957)
            at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:514)
            at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
            at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
            at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
            at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
            at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
            at org.eclipse.jetty.server.Server.doStart(Server.java:282)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at com.windows.services.SimplestServer.main(SimplestServer.java:41)
    Caused by: java.lang.ClassNotFoundException:
    org.apache.juli.logging.LogFactory
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at org.apache.jasper.servlet.JspServlet.(JspServlet.java:68)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at java.lang.Class.newInstance(Unknown Source)
            at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1075)
            at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:957)
            at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:514)
            at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
            at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
            at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
            at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
            at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
            at org.eclipse.jetty.server.Server.doStart(Server.java:282)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at com.windows.services.SimplestServer.main(SimplestServer.java:41)
    2014-02-18 22:43:15.909:WARN:oejuc.AbstractLifeCycle:FAILED
    o.e.j.w.WebAppContext{/,file:/C:/Users/User/AppData/Local/Temp/jetty-0.0.0.0-8000-Je
    .war-</em>-any-/webapp/},C:\Users\User\Desktop\jetty\JettyWar.war:
    java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
    java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
            at org.apache.jasper.servlet.JspServlet.(JspServlet.java:68)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at java.lang.Class.newInstance(Unknown Source)
            at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1075)
            at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:957)
            at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:514)
            at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
            at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
            at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
            at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
            at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
            at org.eclipse.jetty.server.Server.doStart(Server.java:282)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at com.windows.services.SimplestServer.main(SimplestServer.java:41)
    Caused by: java.lang.ClassNotFoundException:
    org.apache.juli.logging.LogFactory
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at org.apache.jasper.servlet.JspServlet.(JspServlet.java:68)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
    Source)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at java.lang.Class.newInstance(Unknown Source)
            at org.eclipse.jetty.servlet.ServletContextHandler$Context.createServlet(ServletContextHandler.java:1075)
            at org.eclipse.jetty.servlet.ServletHolder.newInstance(ServletHolder.java:957)
            at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:514)
            at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)
            at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
            at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
            at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
            at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
            at org.eclipse.jetty.server.Server.doStart(Server.java:282)
            at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
            at com.windows.services.SimplestServer.main(SimplestServer.java:41)</p>
  </blockquote>
  
  <p>I have used jetty 8.1.14.
  I cant understand why I am getting apache's no class def error when I selected j2ee preview in my target runtime. By the way, I got the same error when I had used apache tomcat in runtime. </p>
  
  <p>Also note that I am not using maven or ant. I dont want to use either. I wish to do it through simple java only.</p>
  
  <p>Thank you in advance for helping out.</p>