title: Deploying a war to Jetty with CDI
body: <p>I have a maven project in IntelliJ where I am trying to deploy a war file to a jetty container. The purpose of this is for a quick integration test of some of the functionality in said war file.</p>
  
  <p>Since out of the box Jetty does not come with CDI or JNDI, I am trying to add support for these but running into some issues. For example, I get the following error on startup:</p>
  
  <pre><code>15:30:50 [34mINFO [0;39m o.a.s.c.CdiObjectFactory - [lookup]: Checking for BeanManager under JNDI key java:comp/BeanManager 
  15:30:50 [39mDEBUG[0;39m o.a.s.c.CdiObjectFactory - [lookup]: BeanManager lookup failed for JNDI key java:comp/BeanManager 
  </code></pre>
  
  <p>I have included the weld-servlet jar in my pom and also added the weld listener to the web.xml, however it still does not work. I am using Jetty 9. Any ideas?</p>
  
  <blockquote>
    <p>pom.xml</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.jboss.weld.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;weld-servlet-core&lt;/artifactId&gt;
          &lt;version&gt;2.0.4.Final&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
    
    <p>web.xml</p>
  
  <pre><code>&lt;listener&gt;
    &lt;listener-class&gt;org.jboss.weld.environment.servlet.Listener&lt;/listener-class&gt;
  &lt;/listener&gt;
  </code></pre>
  </blockquote>
  
  <pre><code>&lt;resource-env-ref&gt;
     &lt;description&gt;Object factory for the CDI Bean Manager&lt;/description&gt;
     &lt;resource-env-ref-name&gt;BeanManager&lt;/resource-env-ref-name&gt;
     &lt;resource-env-ref-type&gt;javax.enterprise.inject.spi.BeanManager&lt;/resource-env-ref-type&gt;
  &lt;/resource-env-ref&gt;
  </code></pre>