1 Reply Latest reply on Jul 15, 2009 3:50 PM by Cedric Neve

    WebLogic 10.3 and two beans with Extended Persistence Context

    I need a real name Newbie

      Hello
      I develop application on WebLogic 10.3 and I get Excepion. I give you simple example that demonstrate my problem. I have two beans with Extended Persistence Context and one JSF page.
      First bean



      @Stateful
      @Name( "pong" )
      @Scope(ScopeType.SESSION)
      public class PongBean implements Pong {
              @PersistenceContext(type=PersistenceContextType.EXTENDED)
              private EntityManager em;
              
              public List<SelectItem> getList() {
                      List<SelectItem> ll = new ArrayList<SelectItem>();
                      ll.add( new SelectItem( "1", "1" ) );
                      ll.add( new SelectItem( "2", "2" ) );
                      ll.add( new SelectItem( "3", "3" ) );
                      return ll;
              }
      
              public void setList( List<SelectItem> ll ) {
                      System.out.println( "pong.setList" );
              }
              
              
          @Destroy @Remove
          public void destroy() {}
              
      }
      



      Second bean



      @Stateful
      @Name("ping")
      @Scope(ScopeType.SESSION)
      public class PingBean implements Ping
      {
              @PersistenceContext(type=PersistenceContextType.EXTENDED)
              private EntityManager em;
              
              public void setSelected( List<String> activityTypeList ) {
                      System.out.println( "ping.setType" );
              }
              
              public List<String> getSelected() {
                      List<String> ll = new ArrayList<String>();
                      ll.add( "2" );
                      return ll;
              }
          
      
              public List<SelectItem> getList() {
                      List<SelectItem> ll = new ArrayList<SelectItem>();
                      ll.add( new SelectItem( "1", "1" ) );
                      ll.add( new SelectItem( "2", "2" ) );
                      ll.add( new SelectItem( "3", "3" ) );
                      return ll;
              }
      
              public void setList( List<SelectItem> ll ) {
                      System.out.println( "ping.setList" );
              }
              
              
          @Destroy @Remove
          public void destroy() {}
      
      }
      



      JSF page



      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:a="http://richfaces.org/a4j"
          template="layout/template.xhtml">
      
      <ui:define name="body">
      
          <h:form id="pingForm">
      
              <rich:panel>
                  <f:facet name="header">ping</f:facet>
      
                              <fieldset>
                                      <legend>test_problem</legend>
                                      <rich:pickList value="#{ping.selected}" showButtonsLabel="false" sourceListWidth="200px" targetListWidth="200px">
                                              <f:selectItems value="#{pong.list}"/>
                                      </rich:pickList>
                      </fieldset>
              </rich:panel>
      
      
          </h:form>
      
      </ui:define>
      
      </ui:composition>
      



      My persistence.xml


         <persistence-unit name="test_problem">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>beawebPGXA</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
               <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:/test_problemEntityManagerFactory"/>
               <property name="hibernate.default_schema" value="public"/>
               <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
            </properties>
         </persistence-unit>




      I use Seam 2.1.1 GA. This simple example works on JBoss 4.2.3, on WebLogic 10.3 I get Exception



      javax.faces.FacesException: javax.el.ELException: /ping.xhtml @21,118 value="#{ping.selected}": javax.ejb.EJBTransactionRolledbackException: Error invoking EJB:; nested exception is: javax.ejb.EJBException: Error, the EJB PingBean(Application: test_problem, EJBComponent: test_problem.jar) has an Extended Persistence Context and was invoked  in the context of a transaction that is already  associated with a different Persistence Context
              at javax.faces.component.UIOutput.getValue(UIOutput.java:187)
              at org.richfaces.utils.PickListUtils.getSelectValuesList(PickListUtils.java:96)
              at org.richfaces.utils.PickListUtils.getValuesList(PickListUtils.java:90)
              at org.richfaces.renderkit.PickListRenderer.encodeRows(PickListRenderer.java:131)
              at org.richfaces.renderkit.PickListRenderer.encodeSourceRows(PickListRenderer.java:211)
              at org.richfaces.renderkit.html.PickListRendererGen.doEncodeChildren(PickListRendererGen.java:346)
              at org.richfaces.renderkit.html.PickListRendererGen.doEncodeChildren(PickListRendererGen.java:260)
              at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
              at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
              at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
              at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
              at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
              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:109)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
              at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
              at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
              at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
              at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
              at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              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.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
              at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
              at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
              at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
              at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
              at weblogic.security.service.SecurityManager.runAs(Unknown Source)
              at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
              at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
              at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
              at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
              at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
      Caused by: javax.el.ELException: /ping.xhtml @21,118 value="#{ping.selected}": javax.ejb.EJBTransactionRolledbackException: Error invoking EJB:; nested exception is: javax.ejb.EJBException: Error, the EJB PingBean(Application: test_problem, EJBComponent: test_problem.jar) has an Extended Persistence Context and was invoked  in the context of a transaction that is already  associated with a different Persistence Context
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
              at javax.faces.component.UIOutput.getValue(UIOutput.java:184)
              ... 60 more
      Caused by: javax.ejb.EJBTransactionRolledbackException: Error invoking EJB:; nested exception is: javax.ejb.EJBException: Error, the EJB PingBean(Application: test_problem, EJBComponent: test_problem.jar) has an Extended Persistence Context and was invoked  in the context of a transaction that is already  associated with a different Persistence Context
              at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:794)
              at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:260)
              at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:186)
              at weblogic.ejb.container.internal.StatefulLocalObject.preInvoke(StatefulLocalObject.java:76)
              at promitech.webtimeworklog.PingBean_jgqqx0_PingImpl.getSelected(PingBean_jgqqx0_PingImpl.java:39)
              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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:43)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
              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.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
              at org.javassist.tmp.java.lang.Object_$$_javassist_2.getSelected(Object_$$_javassist_2.java)
              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 javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
              at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
              at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
              at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
              at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
              at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
              ... 61 more




      If I change JSF to



      <f:selectItems value="#{ping.list}"/>




      it is works, no exception. What am I supposed to do? I do not want change JSF.