3 Replies Latest reply on Aug 7, 2011 10:16 AM by jaikiran pai

    Can't find a persistence unit named

    Mitesh pandey Newbie

      Hi All,

       

      I am a newbie to ejb3. For my learning , i created a ejb application with a stateless session bean , a pojo class , a persistence.xml file with hibernate as persistence provider , postgresql as DB and jboss server 5.0.0 CR2.

       

      The external jar added are ejb3-persistence.jar , hibernate-core and hibernate-entitymanager.jar

       

      When i start jboss server , the following error is displayed

       

      ERROR [AbstractKernelController] Error installing to Real: name=vfszip:/E:/software%20download/jboss-5.0.0.CR2-jdk6/jboss-5.0.0.CR2/server/default/deploy/Chapter3.jar state=PreReal mode=Manual requiredState=Real

      org.jboss.deployers.spi.DeploymentException: Error deploying Chapter3.jar: Can't find a persistence unit named 'titan' in AbstractVFSDeploymentContext@25979158{vfszip:/E:/software%20download/jboss-5.0.0.CR2-jdk6/jboss-5.0.0.CR2/server/default/deploy/Chapter3.jar}

                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:209)

                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:108)

                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:169)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1285)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1003)

                at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:944)

                at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)

                at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

                at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)

                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:627)

                at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:541)

                at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:265)

                at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:143)

                at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:409)

                at org.jboss.Main.boot(Main.java:209)

                at org.jboss.Main$1.run(Main.java:544)

                at java.lang.Thread.run(Unknown Source)

      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'titan' in AbstractVFSDeploymentContext@25979158{vfszip:/E:/software%20download/jboss-5.0.0.CR2-jdk6/jboss-5.0.0.CR2/server/default/deploy/Chapter3.jar}

                at org.jboss.jpa.resolvers.DefaultPersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(DefaultPersistenceUnitDependencyResolver.java:141)

                at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:841)

                at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1399)

                at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:124)

                at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76)

                at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:570)

                at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:439)

                at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:552)

                at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:202)

                ... 22 more

      14:13:32,343 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

       

       

      *** CONTEXTS IN ERROR: Name -> Error

       

       

      vfszip:/E:/software%20download/jboss-5.0.0.CR2-jdk6/jboss-5.0.0.CR2/server/default/deploy/Chapter3.jar -> java.lang.IllegalArgumentException: Can't find a persistence unit named 'titan' in AbstractVFSDeploymentContext@25979158{vfszip:/E:/software%20download/jboss-5.0.0.CR2-jdk6/jboss-5.0.0.CR2/server/default/deploy/Chapter3.jar}

       

      The persistence.xml file is as below

       

      <?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">

      <persistence-unit name="titan" transaction-type="JTA">

                 <provider>org.hibernate.ejb.HibernatePersistence</provider>

                 <jta-data-source>java:PostgresDS</jta-data-source>

                 <class>com.domain.Cabin</class>

                <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="false" />

                           <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>

                           <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/Entity"/>

                           <property name="hibernate.connection.username" value="*****"/>

                           <property name="hibernate.connection.password" value="*****"/>

            </properties>

      </persistence-unit>

      </persistence>

       

       

      I have tried other solution like removing the class-path from manifest file but same result is displayed.

       

      Any help is appreciated

        • 1. Re: Can't find a persistence unit named
          Mitesh pandey Newbie

          Hi All,

           

          I think the problem is with the java code where i am injecting the @persistencecontext(unit-name = "titan") private string entitymanager.

          When  i commented the injection. there was no issue with the jboss server . It started properly.

           

          The folder structure are as follows

           

          -ejbModule

               -com

                 --chapter3

                      ---travelAgent.java

                      ---travelAgentlocal.java

                      ---travelAgentRemote.java 

                 --domain

                    --Cabin.java

               -meta-inf

                    --manifest-mf

                    --persistence.xml

           

          I think the problem is  with the folder structure where the persistence injection in the travelAgent is not able to access the persistence.xml

          • 2. Re: Can't find a persistence unit named
            Mitesh pandey Newbie

            Hi All,

             

            Issue resolved. The persistence.xml file name was Persistence.xml. Maybe it is case sensitive due to which it was not able to access the persistence unit

            • 3. Re: Can't find a persistence unit named
              jaikiran pai Master

              Yes, the case is important.

               

              Also it's better you try the examples against either 5.1.0 or 6.0.0 of JBoss AS instead of 5.0.0.CR2