2 Replies Latest reply on Jun 28, 2010 2:06 AM by Daniel Hinojosa

    WHY?? Cannot create Seam component, scope is not active: entityManager(CONVERSATION)

    Sean Li Newbie

      I used seam gen to create UI pages for my user class. When testing the search function of userList.xhtml page, I got this error:




      22:36:56,284 WARN  [org.jboss.seam.Component] Cannot create Seam component, scope is not active: entityManager(CONVERSATION)





      This it not just a warning, but an error, see the stack trace here:


      Caused by java.lang.IllegalStateException with message: "entityManager is null"
      
      org.jboss.seam.framework.EntityQuery.validate(EntityQuery.java:41)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      java.lang.reflect.Method.invoke(Unknown Source)
      org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
      org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
      org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
      org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
      org.jboss.seam.util.Work.workInTransaction(Work.java:61)
      org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
      org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
      org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
      org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
      com.open18.action.UserList_$$_javassist_seam_3.validate(UserList_$$_javassist_seam_3.java)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      java.lang.reflect.Method.invoke(Unknown Source)
      org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
      org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
      org.jboss.seam.Component.callComponentMethod(Component.java:2261)
      org.jboss.seam.Component.callCreateMethod(Component.java:2184)
      org.jboss.seam.Component.newInstance(Component.java:2144)
      org.jboss.seam.Component.getInstance(Component.java:2021)
      org.jboss.seam.Component.getInstance(Component.java:1983)
      org.jboss.seam.Component.getInstance(Component.java:1977)
      org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
      org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
      org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
      org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
      javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
      com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
      org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
      org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
      org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
      javax.faces.component.UIData.getValue(UIData.java:554)
      org.ajax4jsf.component.UIDataAdaptorBase.getValue(UIDataAdaptorBase.java:1647)
      org.ajax4jsf.component.SequenceDataAdaptor.getDataModel(SequenceDataAdaptor.java:65)
      org.ajax4jsf.component.SequenceDataAdaptor.createDataModel(SequenceDataAdaptor.java:59)
      org.richfaces.component.UIDataTable.createDataModel(UIDataTable.java:121)
      org.ajax4jsf.component.UIDataAdaptorBase.getExtendedDataModel(UIDataAdaptorBase.java:621)
      org.ajax4jsf.component.UIDataAdaptorBase.getRowIndex(UIDataAdaptorBase.java:311)
      javax.faces.component.UIData.visitTree(UIData.java:1183)
      javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
      javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
      javax.faces.component.UIViewRoot.processRestoreState(UIViewRoot.java:869)
      org.ajax4jsf.component.AjaxViewRoot.processRestoreState(AjaxViewRoot.java:761)
      org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:456)
      com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:131)
      com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:143)
      org.jboss.seam.jsf.SeamViewHandler.restoreView(SeamViewHandler.java:93)
      com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
      org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:107)
      com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
      com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:336)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:276)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:872)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
      java.lang.Thread.run(Unknown Source)





      I have configured entity manager in components.xml like this:



         <persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/open18EntityManagerFactory"/>





      Tried but couldn't figure out the reason. Please help



        • 1. Re: WHY?? Cannot create Seam component, scope is not active: entityManager(CONVERSATION)
          Jurij Lender Newbie

          Doesn't anyone have a solution? I have the same problem with Seam 2.2.1 and JBoss AS 6 M3

          • 2. Re: WHY?? Cannot create Seam component, scope is not active: entityManager(CONVERSATION)
            Daniel Hinojosa Master

            Is the EntityManagerFactory set up?  You do that via the persistence-....xml file for example:


            <?xml version="1.0" encoding="UTF-8"?>
            <!-- Persistence deployment descriptor for dev profile -->
            <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                         version="1.0">
                         
               <persistence-unit name="myDS">
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>java:/myDS</jta-data-source>
                  <properties>
                     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <!-- Use appropriate dialect here -->
                     <property name="hibernate.hbm2ddl.auto" value="update"/>
                     <property name="hibernate.show_sql" value="true"/>
                     <property name="hibernate.format_sql" value="true"/>
                     <property name="jboss.entity.manager.factory.jndi.name" value="java:/myEntityManagerFactory"/>  <!-- This is your EntityManagerFactory -->
                  </properties>
               </persistence-unit>
            </persistence>
            



            All this is assuming you are using JBoss.