Problema com CDI no Tomcat 7[RESOLVIDO]

Boa noite galera

Estou seguindo a apostila da caelum sobre CDI

Realizei os passos e na hora do deploy estou obtendo a seguinte exception

SEVERE: Exception sending context initialized event to listener instance of class org.jboss.weld.environment.servlet.Listener
org.jboss.weld.exceptions.IllegalStateException: WELD-001202 Error parsing file:/home/bruno/tools/tomcat/apache-tomcat-7.0.14/wtpwebapps/fj26-notas-fiscais/WEB-INF/classes/META-INF/beans.xml
	at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:110)
	at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:138)
	at org.jboss.weld.bootstrap.WeldBootstrap.parse(WeldBootstrap.java:519)
	at org.jboss.weld.environment.servlet.deployment.WebAppBeanDeploymentArchive.<init>(WebAppBeanDeploymentArchive.java:81)
	at org.jboss.weld.environment.servlet.deployment.ServletDeployment.createWebAppBeanDeploymentArchive(ServletDeployment.java:34)
	at org.jboss.weld.environment.servlet.deployment.ServletDeployment.<init>(ServletDeployment.java:25)
	at org.jboss.weld.environment.servlet.Listener.createServletDeployment(Listener.java:111)
	at org.jboss.weld.environment.servlet.Listener.contextInitialized(Listener.java:158)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
	at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Oct 10, 2011 9:17:21 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.0.4 (FCS b09) for context '/fj26-notas-fiscais'
Oct 10, 2011 9:17:21 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present.  ManagedBeans methods marked with these annotations will have said annotations processed.
Oct 10, 2011 9:17:21 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Oct 10, 2011 9:17:21 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/fj26-notas-fiscais] startup failed due to previous errors
Oct 10, 2011 9:17:21 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: 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:58)
	at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:500)
	at org.jboss.weld.environment.servlet.Listener.contextDestroyed(Listener.java:91)
	at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4763)
	at org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5472)
	at java.lang.Thread.run(Thread.java:662)
	at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5481)
	at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
Oct 10, 2011 9:17:21 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

Eu criei um arquivo beans.xml em branco e coloquei na pasta src/META-INF junto com o persistence.xml

O que tem de errado nele?

Eu adicionei o jar do wel-servlet.jar na pasta lib junto com os outros jars.

E meu web.xml ficou assim

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>fj26-notas-fiscais</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <listener>
  	<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
  </listener>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
  
</web-app>

Se alguém puder me ajudar ficarei grato

Atenciosamente

cara,

coloque o beans.xml dentro da pasta WEB-INF com o seguinte conteudo e ve se funciona.

<?xml version="1.0"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd"/>

t+

1 curtida

N√£o funcionou =/

da uma olhada nesse video e ve se te ajuda

[youtube]


[/youtube]

t+

resolvido

http://rafaelliu.net/2011/05/29/weld-no-tomcat-7/

Valewww

Galera (é o meu primeiro post , nao sei se estou no lugar certo !!) estou tentando rodar O TOMCAT 7 COM cdi e esta me dando esse erro

GRAVE: Error configuring application listener of class org.jboss.weld.environment.servlet.Listener
java.lang.ClassNotFoundException: org.jboss.weld.environment.servlet.Listener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Se alguem puder dar uma luz pois ja revirei e nao achei nada

Passei por esse mesmo problema. No meu caso era conflito de lib’s. Removi a lib guava-r06.jar e funcionou.

Espero que ajude.

1 curtida

[quote=brunorota]resolvido

http://rafaelliu.net/2011/05/29/weld-no-tomcat-7/

Valewww[/quote]

Bruno, estou com um problema como o seu, entrei no link que resolveu o seu problema mas o seguinte…

onde que vou colocar o que o cara do site disse:

devo criar dentro da META-INF uma pasta chamada services ? e onde coloco todo o resto…

como que você fez ? compartilha ai…

Abraço