4 Replies Latest reply on Nov 28, 2008 6:23 PM by Jose Rubio

    Problem in using more than one entity manager with entity converter in Seam 2.1

    Anil Erukala Newbie
      I am upgrading my project from Seam 2.0.0.GA to Seam 2.1.0.GA. With Seam 2.0.0.GA I was able to set up more than one entity manager with entity converter. But it is not working with Seam 2.1.0.GA. I followed the reference documentation. But I think I am missing something.

      I am using JPA. I have two databases. One persistence unit is called entityManager and another one is called entityManagerIDM. s:convertEntity is working fine with the dropdowns from first DB (entityManager). But when I use entity converter with second database I am getting error

      java.lang.IllegalStateException: EntityManager is closed
           at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:42)


      Components.xml



      `<components xmlns="http://jboss.com/products/seam/components"
      xmlns:ui="http://jboss.com/products/seam/ui">

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

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

      <ui:jpa-entity-loader name="idmEntityLoader" entity-manager="#{entityManagerIDM}"/>     

      <ui:entity-converter name="idmEntityConverter" entity-loader="#{idmEntityLoader}"/>`



      xhtml page where I am using entity converter.


      `<h:selectOneListbox size="1"
      value="#{developmentDetailsAction.development.directSalesRep}">
            <s:selectItems value="#   {developmentDetailsAction.getDirectSalesReps()}"                         label="#{directSalesRepresent.firstname} #{directSalesRepresent.lastname}"          var="directSalesRepresent" noSelectionLabel="Choose" />
           <f:converter converterId="idmEntityConverter" />
      </h:selectOneListbox>`


      If I remove <f:converter converterId="idmEntityConverter" /> I am able to see the drop down but when I select it says value is not valid (obviously). When I use converter I am getting the entityManager is closed error.

      Please let me know what I am missing.

      Thanks,
      Anil Erukala
        • 1. Re: Problem in using more than one entity manager with entity converter in Seam 2.1
          Anil Erukala Newbie
          Here is the full stack trace:

          2008-11-04 10:26:46,551 WARN  [org.jboss.seam.web.ExceptionFilter] exception root cause
          java.lang.IllegalStateException: EntityManager is closed
               at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:42)
               at org.hibernate.ejb.AbstractEntityManagerImpl.getDelegate(AbstractEntityManagerImpl.java:570)
               at org.jboss.seam.persistence.EntityManagerProxy.getDelegate(EntityManagerProxy.java:97)
               at org.jboss.seam.persistence.HibernatePersistenceProvider.getSession(HibernatePersistenceProvider.java:355)
               at org.jboss.seam.persistence.HibernatePersistenceProvider.getId(HibernatePersistenceProvider.java:163)
               at org.jboss.seam.framework.EntityIdentifier.<init>(EntityIdentifier.java:13)
               at org.jboss.seam.ui.JpaEntityLoader.createIdentifier(JpaEntityLoader.java:29)
               at org.jboss.seam.ui.AbstractEntityLoader.put(AbstractEntityLoader.java:46)
               at sun.reflect.GeneratedMethodAccessor316.invoke(Unknown Source)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:585)
               at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
               at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
               at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:40)
               at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
               at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:34)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
               at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
               at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
               at org.jboss.seam.ui.JpaEntityLoader_$$_javassist_4.put(JpaEntityLoader_$$_javassist_4.java)
               at org.jboss.seam.ui.EntityConverter.getAsString(EntityConverter.java:67)
               at org.jboss.seam.ui.converter.PrioritizableConverter.getAsString(PrioritizableConverter.java:67)
               at org.jboss.seam.ui.converter.ConverterChain.getAsString(ConverterChain.java:126)
               at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getFormattedValue(HtmlBasicRenderer.java:469)
               at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:502)
               at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:757)
               at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:811)
               at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
               at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
               at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
               at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
               at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:276)
               at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:117)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
               at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
               at org.jboss.seam.ui.renderkit.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:146)
               at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
               at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:117)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
               at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
               at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
               at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284)
               at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
               at org.richfaces.renderkit.html.SimpleToggleControlTemplate.doEncodeChildren(SimpleToggleControlTemplate.java:347)
               at org.richfaces.renderkit.html.SimpleToggleControlTemplate.doEncodeChildren(SimpleToggleControlTemplate.java:342)
               at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
               at org.richfaces.renderkit.html.SimpleTogglePanelRenderer.encodeChildren(SimpleTogglePanelRenderer.java:208)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
               at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
               at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
               at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
               at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:186)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:188)
               at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
               at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
               at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
               at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
               at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284)
               at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
               at org.richfaces.renderkit.TabRendererBase.encodeChildren(TabRendererBase.java:113)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
               at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
               at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:286)
               at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:281)
               at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
               at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
               at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:124)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
               at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
               at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
               at org.ajax4jsf.component.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:267)
               at org.ajax4jsf.component.AjaxViewRoot$4.invokeContextCallback(AjaxViewRoot.java:489)
               at org.ajax4jsf.component.ContextCallbackWrapper.invokeContextCallback(ContextCallbackWrapper.java:24)
               at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:672)
               at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
               at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
               at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
               at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
               at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
               at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
               at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
               at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
               at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
               at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
               at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
               at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:681)
               at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:650)
               at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:543)
               at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
               at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
               at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
               at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
               at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
               at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
               at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:118)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
               at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
               at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
               at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
               at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
               at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
               at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
               at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
               at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
               at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
               at java.lang.Thread.run(Thread.java:595)



          • 2. Re: Problem in using more than one entity manager with entity converter in Seam 2.1
            Anil Erukala Newbie
            I also added <transaction:ejb-transaction /> to the above components.xml. But still I am getting the same error.

            Could somebody please reply to my above question? This is urgent.

            Thanks,
            Anil
            • 3. Re: Problem in using more than one entity manager with entity converter in Seam 2.1
              kristjan slomsek Newbie

              Hi,



              I have exactly the same problem, also two databases. Anyone with more knowledge can help please?


              tnx and brg,
              K

              • 4. Re: Problem in using more than one entity manager with entity converter in Seam 2.1
                Jose Rubio Newbie

                Were you able to find a solution to your problem? I'm having the exact same situation. My second data source is getting the EntityManager closed exception.