title: create a executable jar using maven and jetty
body: <p>I want to start my application using jetty, so I have added the dependency mentioned below. and when I run the main method Jetty starts successfully.(I am working on a struts2+spring3+ hibernate maven project, i am able to deploy it in tomcat too)</p>
  
  <p>Now I want to create a executable jar from a war packaging pom. So i added <strong>maven-assembly-plugin</strong> to my pom. (I tried with maven jar plug-in but it was not adding the dependencies) </p>
  
  <h2>Sources</h2>
  
  <p><strong>plugins</strong> </p>
  
  
  
  <pre class="lang-xml prettyprint-override"><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
          &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.3&lt;/version&gt;
          &lt;configuration&gt;
                   &lt;archive&gt;
              &lt;manifest&gt;
          &lt;mainClass&gt;com.dca.engine.StartDCA&lt;/mainClass&gt;
              &lt;/manifest&gt;
               &lt;/archive&gt;
          &lt;packagingExcludes&gt;WEB-INF/lib/jetty*.jar,WEB-INF/lib/org.apache.taglibs.standard.glassfish*.jar,WEB-INF/lib/org.apache.jasper.glassfish*.jar,WEB-INF/lib/org.eclipse.jdt.core*.jar,WEB-INF/lib/javax.servlet.jsp*.jar,WEB-INF/lib/javax.el*.jar&lt;/packagingExcludes&gt;
          &lt;escapeString&gt;\&lt;/escapeString&gt;
          &lt;/configuration&gt;
         &lt;/plugin&gt;
         &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.4&lt;/version&gt;
          &lt;configuration&gt;
                   &lt;descriptorRefs&gt;
                          &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                   &lt;/descriptorRefs&gt;
               &lt;archive&gt;
              &lt;manifest&gt;
          &lt;mainClass&gt;com.dca.engine.StartDCA&lt;/mainClass&gt;
              &lt;/manifest&gt;
               &lt;/archive&gt;
          &lt;/configuration&gt;
          &lt;executions&gt;
               &lt;execution&gt;
                      &lt;id&gt;make-assembly&lt;/id&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                        &lt;goal&gt;single&lt;/goal&gt;
                      &lt;/goals&gt;
               &lt;/execution&gt;
          &lt;/executions&gt;
      &lt;/plugin&gt;
   &lt;/plugins&gt;
  &lt;resources&gt;
      &lt;resource&gt;
          &lt;directory&gt;src/main/java&lt;/directory&gt;
          &lt;includes&gt;
          &lt;include&gt;**/*.java&lt;/include&gt;
          &lt;include&gt;**/*.xml&lt;/include&gt;
          &lt;/includes&gt;
      &lt;/resource&gt;
      &lt;resource&gt;
          &lt;directory&gt;src/main/resources&lt;/directory&gt;
          &lt;filtering&gt;true&lt;/filtering&gt;
      &lt;/resource&gt;
  &lt;/resources&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p><strong>Embedded Jetty</strong></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
      &lt;artifactId&gt;jetty-server&lt;/artifactId&gt;
      &lt;version&gt;8.1.10.v20130312&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
      &lt;artifactId&gt;jetty-webapp&lt;/artifactId&gt;
      &lt;version&gt;8.1.10.v20130312&lt;/version&gt;
      &lt;!-- &lt;scope&gt;provided&lt;/scope&gt; --&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
      &lt;artifactId&gt;jetty-jsp&lt;/artifactId&gt;
      &lt;version&gt;8.1.10.v20130312&lt;/version&gt;
      &lt;!-- &lt;scope&gt;provided&lt;/scope&gt;  --&gt;
  &lt;/dependency&gt; 
  </code></pre>
  
  <p><strong>main method</strong></p>
  
  <pre class="lang-java prettyprint-override"><code> Server server = new Server(8080);
          System.setProperty("is_DCA", "YES");
          WebAppContext webAppContext = new WebAppContext();
          webAppContext.setResourceBase("/home/myfolder/workspace/app/dca/src/main/webapp");
          webAppContext.setDescriptor("/home/myfolder/workspace/app/dca/src/main/webapp/WEB-INF/web.xml");
          webAppContext.setContextPath("/app");
          server.setHandler(webAppContext);
          server.start();
          server.join();
  </code></pre>
  
  <h2>Starting the application</h2>
  
  <p>I run the created jar with java -jar /home/myfolder/workspace/app/dca/target/app-dca-1.0-jar-with-dependencies.jar</p>
  
  <p>jetty starts with exception.</p>
  
  <pre class="lang-xml prettyprint-override"><code>INFO  10-12 15:03:01,609 - jetty-8.y.z-SNAPSHOT
  INFO  10-12 15:03:01,776 - Initializing Spring root WebApplicationContext
  INFO  10-12 15:03:01,776 - Root WebApplicationContext: initialization started
  INFO  10-12 15:03:01,843 - Refreshing Root WebApplicationContext: startup date [Tue Dec 10 15:03:01 IST 2013]; root of context hierarchy
  INFO  10-12 15:03:01,885 - Loading XML bean definitions from class path resource [applicationContext-dca.xml]
  ERROR 10-12 15:03:05,725 - Context initialization failed
  org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/util]
  Offending resource: class path resource [applicationContext-dca.xml]
  
      at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
      at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1420)
      at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1413)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
      at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
  </code></pre>
  
  <p>Is there a possible way that i can start jetty using the war created. It has jars in /WEB-INF/lib/ folder, all properties file and xml files are in /WEB-INF/lib/ and I tried running the war  </p>
  
  <blockquote>
    <p>java -jar /home/myfolder/workspace/app/dca/target/app-dca-1.0.war</p>
  </blockquote>
  
  <p>but it was not able to locate the main class.</p>
  
  <p><strong>worked when created executable war check sumit's <a href="https://stackoverflow.com/a/20496765/2334391">answer</a></strong></p>
  
  <p>I was getting the exception <a href="https://stackoverflow.com/q/20559564/2334391">as in this question</a>. when I replaced jetty version to  7.6.7.v20120910 it worked</p>
  
  <p>i dont know why it didn't worked with jetty 8.1.10.v20130312  </p>