8 Replies Latest reply on Mar 17, 2011 6:28 AM by jaikiran pai

    Losing persistence context in hot-deployment

    Nicklas Karlsson Master

      AS 6 Final.

       

      I have two WAR:s which both have a single persistence unit defined (against different datasources). After some undeploying and deploying I sometimes end up with a EJB @PersistenceContext injection complaining that it no longer can determine which persistence unit to use. Anyone seen this?

        • 1. Losing persistence context in hot-deployment
          jaikiran pai Master

          Nicklas Karlsson wrote:

           

          AS 6 Final.

           

          I have two WAR:s which both have a single persistence unit defined (against different datasources).

          You mean same PU name?

           

           

          Nicklas Karlsson wrote:

           

          After some undeploying and deploying I sometimes end up with a EJB @PersistenceContext injection complaining that it no longer can determine which persistence unit to use.

          Do you use the "unitName" attribute in the @PersistenceContext injection? What does that piece of code look like?

           

           

           

          Nicklas Karlsson wrote:

           

          complaining that it no longer can determine which persistence unit to use. Anyone seen this?

          Could you post that exception stacktrace? Probably the code which scans for the PUs in the deployment units might have something going on.

          • 2. Losing persistence context in hot-deployment
            Nicklas Karlsson Master

            Different PU:s

             

            I'm using

             

            @PersistenceContext

            EntityManager em;

             

            since I only have one PU in my persistence.xml anyway

             

            The trace is

            Caused by: java.lang.RuntimeException: Unable to determine persistenceContext: persistence.unit:unitName=LTK.war#LTK in injected SFSB: jboss.j2ee:jar=LTK.war,name=Logintoiminnot,service=EJB3

                      at org.jboss.ejb3.entity.ExtendedEntityManager.getPersistenceContext(ExtendedEntityManager.java:78) [:1.7.17]

                      at org.jboss.ejb3.entity.ExtendedEntityManager.getEntityManager(ExtendedEntityManager.java:61) [:1.7.17]

                      at org.jboss.ejb3.jpa.integration.JPA1EntityManagerDelegator.find(JPA1EntityManagerDelegator.java:81) [:2.0.0-alpha-1]

                      at fi.affecto.ltk.kirjautuminen.Logintoiminnot.kirjauduSisään(Logintoiminnot.java:58) [classe:]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:127) [:1.1.3]

                      at org.jboss.weld.integration.ejb.interceptor.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:151) [:6.0.0.Final]

                      at org.jboss.weld.integration.ejb.interceptor.Jsr299BindingsInterceptor.doAroundInvoke(Jsr299BindingsInterceptor.java:122) [:6.0.0.Final]

                      at sun.reflect.GeneratedMethodAccessor307.invoke(Unknown Source) [:1.6.0_23]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                      at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:80) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:71) [:1.1.3]

                      at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:62) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:127) [:1.1.3]

                      at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:46) [:2011-01-10 09:56]

                      at sun.reflect.GeneratedMethodAccessor306.invoke(Unknown Source) [:1.6.0_23]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                      at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:80) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:71) [:1.1.3]

                      at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:62) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:76) [:1.1.3]

                      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:62) [:1.1.3]

                      at sun.reflect.GeneratedMethodAccessor305.invoke(Unknown Source) [:1.6.0_23]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]

                      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]

                      at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:74) [:1.1.3]

                      at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_977487565.invoke(InvocationContextInterceptor_z_fillMethod_977487565.java) [:]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:90) [:1.1.3]

                      at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_977487565.invoke(InvocationContextInterceptor_z_setup_977487565.java) [:]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.async.impl.interceptor.AsynchronousServerInterceptor.invoke(AsynchronousServerInterceptor.java:128) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:60) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.stateful.SessionSynchronizationInterceptor.invoke(SessionSynchronizationInterceptor.java:252) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42) [:1.0.3]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.stateful.StatefulCacheInterceptor.invoke(StatefulCacheInterceptor.java:65) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.concurrency.aop.interceptor.ContainerManagedConcurrencyInterceptor.invoke(ContainerManagedConcurrencyInterceptor.java:181) [:1.0.0-alpha-4]

                      at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:86) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.stateful.StatefulInstanceAssociationInterceptor.invoke(StatefulInstanceAssociationInterceptor.java:55) [:1.7.17]

                      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                      at org.jboss.ejb3.core.context.SessionInvocationContextAdapter.proceed(SessionInvocationContextAdapter.java:95) [:1.7.17]

                      at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:247) [:0.0.1]

                      ... 90 more

            • 3. Losing persistence context in hot-deployment
              jaikiran pai Master

              Caused by: java.lang.RuntimeException: Unable to determine persistenceContext: persistence.unit:unitName=LTK.war#LTK in injected SFSB: jboss.j2ee:jar=LTK.war,name=Logintoiminnot,service=EJB3

                        at org.jboss.ejb3.entity.ExtendedEntityManager.getPersistenceContext(ExtendedEntityManager.java:78) [:1.7.17]

                        at org.jboss.ejb3.entity.ExtendedEntityManager.getEntityManager(ExtendedEntityManager.java:61) [:1.7.17]

              Is this EXTENDED type PersistenceContext?

              • 5. Losing persistence context in hot-deployment
                jaikiran pai Master

                Is there an application which you can share to reproduce this issue? The extended PC shouldn't have been used unless that's what is being asked for.

                • 6. Losing persistence context in hot-deployment
                  Nicklas Karlsson Master

                  I'll first try to find the correct deploy/undeploy cycle in order to reproduce it systematically

                  • 7. Losing persistence context in hot-deployment
                    Nicklas Karlsson Master

                    I still get this issue (even on a single deployment) and I saw on irc that Dan Allen got it too when working on the seam booking demo.

                     

                    Is anyone else getting the issue of failing to find a persistence context to inject (with a single persistence unit)? I'm on viewless EJBs in a WAR. Any patterns? Qualifying the unitName doesn't help either...

                    • 8. Losing persistence context in hot-deployment
                      jaikiran pai Master

                      If it can't be reproduced everytime then I guess it's some race condition or something along those lines. The next this happens, please  copy the server.log and also the application which generated this and attach it to this thread or maybe even a JIRA. That might help us narrow down the issue.