1 Reply Latest reply on Nov 11, 2010 8:14 AM by Paulo Braga

    Tomcat 7 + JSF 2 + Weld

    Paulo Braga Newbie

      Hello, I'm trying to configure Weld in my application and I'm getting de following error:




      org.jboss.weld.exceptions.ForbiddenArgumentException: WELD-000702 Unable to find BeanManager for org.apache.catalina.core.ApplicationContextFacade@76cfab
           at org.jboss.weld.servlet.ServletHelper.getModuleBeanManager(ServletHelper.java:44)
           at org.jboss.weld.servlet.BeanProvider.conversationManager(BeanProvider.java:44)
           at org.jboss.weld.jsf.WeldPhaseListener.initiateSessionAndConversation(WeldPhaseListener.java:166)
           at org.jboss.weld.jsf.WeldPhaseListener.beforeRestoreView(WeldPhaseListener.java:118)
           at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:87)
           at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:224)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:95)
           at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:203)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
           at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:259)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:237)
           at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:281)
           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:619)



      and, my web.xml is:




      <web-app 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://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
           version="3.0">
      
           <!-- Spring Activation 
           <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
           </listener>
           <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/applicationContext.xml</param-value>
           </context-param>-->
      
      
           <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>*.jsf</url-pattern>
           </servlet-mapping>
      
           <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>
      
      </web-app>



      and I have the beans.xml and faces-config.xml empty.


      My managed bean is:




      @ManagedBean(name = "bean")
      @RequestScoped
      public class Teste extends HttpServlet implements Serializable{
      
           private static final long serialVersionUID = -3620237074353031348L;
           
           @Inject
           TesteRepository hammer;
           
           private String texto;
           
           public void usaRepo(){
                hammer.falaAlgo();
           }
      
           public String getTexto() {
                return texto;
           }
      
           public void setTexto(String texto) {
                this.texto = texto;
           }
      
      }



      and my xhtml is:



      <html xmlns="http://www.w3.org/1999/xhtml"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core">
           <h:head>
                <title>Ajax com JSF 2.0</title>
           </h:head>
           <h:body>
                <h:form id="form1">
                     <h:outputScript name="jsf.js" library="javax.faces" target="head" />
                     <h:inputText id="texto" value="#{bean.texto}">
                          <f:ajax event="keyup" execute="form1:texto" render="form1:resultado" />
                     </h:inputText>
                     <br />
                     Resultado:
                     <strong> 
                          <h:outputLabel id="resultado" value="#{bean.texto}" /> 
                     </strong>
                     <h:commandLink action="#{bean.usaRepo}" value="teste"/>
                </h:form>
           </h:body>
      </html>



      So, when I try to access teste.jsf, I get the error that I messioned.


      Any sugestions?


      Thanks and sorry for my bad english.