Problem with Weld CDI with TomCat server

4

Hello everyone, I'm having trouble using the CDI implementation, Weld on Tomcat 7. I've been researching and tried several proposed solutions, but all these solutions are old, with dates of 2012. None of these solutions worked.

Let the settings and versions:

Versions: Tomcat 7, JSF 2.1, Weld 2.1.0.Final

Settings:

beans.xml (src / META-INF / beans.xml): BLANK FILE context.xml (src / META-INF / context.xml)

<?xml version="1.0" encoding="UTF-8"?>
<Context>  
   <Manager pathname=""/> <!-- disables storage of sessions across restarts -->  
   <Resource name="BeanManager"        
          auth="Container"      
          type="javax.enterprise.inject.spi.BeanManager"   
          factory="org.jboss.weld.resources.ManagerObjectFactory"/>     
</Context>

Jar Placed as Maven Project

link

<!-- Weld (implementação do CDI) -->
<dependency>
    <groupId>org.jboss.weld.servlet</groupId>
    <artifactId>weld-servlet</artifactId>
    <version>1.1.10.Final</version>
    <scope>compile</scope>
</dependency>

web.xml

<listener>
    <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
  </listener>

  <resource-env-ref>
    <resource-env-ref-name>BeanManager</resource-env-ref-name>
    <resource-env-ref-type>
        javax.enterprise.inject.spi.BeanManager
    </resource-env-ref-type>
  </resource-env-ref>

I SUBMIT MY TOMCAT AND BY ENTERING MY index.xhtml, I RECEIVE THE FOLLOWING ERROR:

GRAVE: Exception sending context destroyed event to listener instance of class org.jboss.weld.environment.servlet.Listener
java.lang.IllegalStateException: Singleton is not set
    at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:52)
    at org.jboss.weld.Container.instance(Container.java:54)
    at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:466)
    at org.jboss.weld.environment.servlet.Listener.contextDestroyed(Listener.java:83)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5064)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5726)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    
asked by anonymous 09.12.2015 / 18:54

0 answers