Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-5043

Don't find the good persistence unit when multiple ear with same pu name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • JBossAS-5.0.0.CR1
    • JBossAS-4.2.1.GA, JBossAS-4.2.2.GA
    • EJB
    • None

    Description

      When using multiple ear with multiple persistence unit having the same name, Jboss uses the wrong persistence unit when deploying ejb and the exception "Entity is not mapped" occures when entities are accessed.
      This behaviour seams to be in contradiction with the Java Persistence API Spec (see ยง 6.2.2).

      Example :
      app1.ear and app2.ear with two persistence unit having the same persistence unit name "pu".

      While deploying app2.ear, the following message can be seen in the JBoss log :
      2007-11-30 15:13:03,865 DEBUG [org.jboss.injection.PersistenceUnitHandler] ***** adding PU dependency from located persistence unit: persistence.units:ear=app1.ear,unitName=pu

      When accessing EJB deployed in app2.ear, the following exception occures :
      javax.ejb.EJBTransactionRolledbackException: org.hibernate.hql.ast.QuerySyntaxException: TestEntity is not mapped [From TestEntity t where t.id = :id]
      at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
      at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:166)
      at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:115)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
      at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
      at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)

      The following patch seems to make JBoss find the good persistence unit :

      In file org.jboss.ejb3.enc.DeploymentPersistenceUnitResolver.java on line 106 :

      replace :

      if (deployment.getEntityManagerName().equals(unitName)) return deployment;

      with :

      if (deployment.getEntityManagerName().equals(unitName) && deployment.getKernelName().contains(deploymentScope.getBaseName())) return deployment;

      Attachments

        Issue Links

          Activity

            People

              wdecoste1@redhat.com William Decoste (Inactive)
              jpoittevin Jerome Poittevin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: