4
Greeting to everyone, I’m having trouble using the CDI implementation, Weld on Tomcat 7. I’ve been doing some research and tried several proposed solutions, but all these solutions are old, with dates of 2012. None of these solutions worked.
Let’s go 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
http://seamframework.org/Weld/Home.html
<!-- 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 RAISE MY TOMCAT AND WHEN I ENTER 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)
Try to move the
beans.xml
forsrc/main/webapp/WEB-INF
. Thecontext.xml
you aim with the property containerConfigXML of the WAR plugin. The goal is that inside the War the paths are respectivelyWEB-INF/beans.xml
andMETA-INF/context.xml
.– Anthony Accioly