12 Replies Latest reply on Jul 20, 2009 12:52 PM by Jeremy Whiting

    Persistence Unit not found for EJB3 SLSB in AS 5.1.0.GA

    Jeremy Whiting Expert

      Hi,
      An EJB3 SLSB I have is not loading on the current latest version of JBoss AS 5.1.0.GA. I am using Fedora release 10, Kernel Linux 2.6.27.25 and Java version "1.6.0_13".

      The error message is:

      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'mvccsample' in AbstractVFSDeploymentContext@12556446{vfszip:/home/whitingjr/java/jboss-5.1.0.GA/server/default/deploy/MVCCSampleEAR.ear/}


      My application is an EAR module with a child EJB module. A very simple setup for the research project I am working on. This module has worked on JBoss AS 4.2.2. I have been through the migration process to upgrade the xml configuration files jboss-app.xml and persistence.xml

      EAR module
      META-INF/
      application.xml
      jboss-app.xml

      EJB module
      META-INF/
      ejb-jar.xml
      persistence.xml
      1 EJB3 stateless session bean

      The EJB3 SLSB has an EntityManager field annotated with @PersistenceContext. The persistence context is named 'mvccsample'.

      @Stateless(name = "PersonManager")
      public class PersonManagerBean implements PersonManagerRemote, PersonManagerLocal {
      
       @PersistenceContext (unitName="mvccsample")
       private EntityManager entityManager;
      


      This is the persistence.xml

      <?xml version="1.0" encoding="utf-8"?>
      <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">
      
       <!-- jboss v5 -->
       <persistence-unit name="mvccsample" transaction-type="JTA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:/DefaultDS</jta-data-source>
      
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
       <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      
       </properties>
       </persistence-unit>
      </persistence>


      I am expecting the configured persistence unit (in the EJB module) to be resolved because it is in scope. The persistence unit 'mvccsample' is not being used outside of the EJB module which the EJB3 spec indicates is not allowed.

      I have modified the class org.jboss.jpa.resolvers.strategy.BaseSearchStrategy to get my EAR module to load sucessfully but I wondered if I have overlooked something in the configuration or SLSB ?


      Here is the full error stack trace.

      2009-07-16 19:08:32,504 TRACE [org.jboss.ejb3.Ejb3Deployment] (main) Process EJB container metadata jboss.j2ee:ear=MVCCSampleEAR.ear,jar=MVCCSampleEAR.ear,name=PersonManager,service=EJB3
      2009-07-16 19:08:32,522 ERROR [org.jboss.ejb3.Ejb3Deployment] (main) Exception while processing container metadata for EJB: PersonManager in unit: MVCCSampleEAR.ear
      2009-07-16 19:08:32,522 DEBUG [org.jboss.ejb3.Ejb3Deployment] (main) error trying to stop ejb container: jboss.j2ee:ear=MVCCSampleEAR.ear,jar=MVCCSampleEAR.ear,name=PersonManager,service=EJB3
      javax.management.InstanceNotFoundException: jboss.j2ee:ear=MVCCSampleEAR.ear,jar=MVCCSampleEAR.ear,name=PersonManager,service=EJB3 is not registered.
       at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:526)
       at org.jboss.mx.server.MBeanServerImpl.unregisterMBean(MBeanServerImpl.java:383)
       at org.jboss.ejb3.Ejb3Deployment.stop(Ejb3Deployment.java:595)
       at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:538)
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189)
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:99)
       at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
       at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
       at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
       at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
       at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
       at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
       at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
       at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
       at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
       at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
       at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
       at org.jboss.Main.boot(Main.java:221)
       at org.jboss.Main$1.run(Main.java:556)
       at java.lang.Thread.run(Thread.java:619)
      2009-07-16 19:08:32,522 DEBUG [org.jboss.ejb3.Ejb3Registry] (main) Unregistered container jboss.j2ee:ear=MVCCSampleEAR.ear,jar=MVCCSampleEAR.ear,name=PersonManager,service=EJB3,VMID=11d1def534ea1be0:-4f2aa254:12284bfedbc:-7f9b
      2009-07-16 19:08:32,523 DEBUG [org.jboss.ejb3.deployers.Ejb3Deployer] (main) Error during deploy: vfszip:/home/whitingjr/java/jboss-5.1.0.GA/server/default/deploy/MVCCSampleEAR.ear/
      org.jboss.deployers.spi.DeploymentException: Error deploying MVCCSampleEAR.ear: Exception while processing container metadata for EJB: PersonManager in unit: MVCCSampleEAR.ear
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:99)
       at org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer.internalDeploy(AbstractVFSRealDeployer.java:45)
       at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
       at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
       at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
       at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
       at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
       at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
       at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
       at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
       at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
       at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
       at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
       at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
       at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
       at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
       at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
       at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
       at org.jboss.Main.boot(Main.java:221)
       at org.jboss.Main$1.run(Main.java:556)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.Exception: Exception while processing container metadata for EJB: PersonManager in unit: MVCCSampleEAR.ear
       at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:549)
       at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:189)
       ... 33 more
      Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=MVCCSampleEAR.ear,jar=MVCCSampleEAR.ear,name=PersonManager,service=EJB3 failed to resolve persistence unit mvccsample
       at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:135)
       at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76)
       at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:588)
       at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:418)
       at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:527)
       ... 34 more
      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'mvccsample' in AbstractVFSDeploymentContext@12556446{vfszip:/home/whitingjr/java/jboss-5.1.0.GA/server/default/deploy/MVCCSampleEAR.ear/}
       at org.jboss.jpa.resolvers.BasePersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(BasePersistenceUnitDependencyResolver.java:107)
       at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:770)
       at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1428)
       at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130)
       ... 38 more


      Can you help ?