13 Replies Latest reply on Jan 12, 2009 8:42 AM by omergillani

    Plz help me asap!

    omergillani

      I am trying to use EntityManger in statless bean
      @PersistenceContext(unitName="HRPU") annotation.

      03:14:36,392 INFO [QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000
      03:14:36,517 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled, lease period 10000 milliseconds
      03:14:36,517 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1313905 started
      03:14:36,520 INFO [QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
      03:14:36,521 WARN [ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover
      03:14:36,521 WARN [ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing
      03:14:36,530 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled, lease period 10000 milliseconds
      03:14:36,530 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1487cd2 started
      03:14:36,533 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled, lease period 10000 milliseconds
      03:14:36,533 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory@1001872 started
      03:14:36,772 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
      03:14:36,885 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=mySQLDS' to JNDI name 'java:mySQLDS'
      03:14:36,961 INFO [TomcatDeployment] deploy, ctxPath=/, vfsUrl=ROOT.war
      03:14:37,054 INFO [TomcatDeployment] deploy, ctxPath=/jmx-console, vfsUrl=jmx-console.war
      03:14:39,333 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/D:/Workspace/Final%20Project/HR%20Module%20Final/Workspace/Application%20Server/jboss-5.0.0.GA-jdk6/jboss-5.0.0.GA/server/default/deploy/HR.ear/ state=PreReal mode=Manual requiredState=Real
      org.jboss.deployers.spi.DeploymentException: Error deploying HR.ear: Container jboss.j2ee:ear=HR.ear,jar=HR.ear,name=OperationServiceBean,service=EJB3 failed to resolve persistence unit HRPU
      at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:203)
      at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:104)
      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: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:781)
      at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545)
      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
      at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
      at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
      at org.jboss.Main.boot(Main.java:209)
      at org.jboss.Main$1.run(Main.java:547)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.IllegalArgumentException: Container jboss.j2ee:ear=HR.ear,jar=HR.ear,name=OperationServiceBean,service=EJB3 failed to resolve persistence unit HRPU
      at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:130)
      at org.jboss.injection.PersistenceContextHandler.loadXml(PersistenceContextHandler.java:76)
      at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:584)
      at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:415)
      at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:523)
      at org.jboss.ejb3.deployers.Ejb3Deployer.deploy(Ejb3Deployer.java:196)
      ... 22 more
      Caused by: java.lang.IllegalArgumentException: Can't find a persistence unit named 'HRPU' in AbstractVFSDeploymentContext@17659299{vfsfile:/D:/Workspace/Final%20Project/HR%20Module%20Final/Workspace/Application%20Server/jboss-5.0.0.GA-jdk6/jboss-5.0.0.GA/server/default/deploy/HR.ear/}
      at org.jboss.jpa.resolvers.DefaultPersistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(DefaultPersistenceUnitDependencyResolver.java:141)
      at org.jboss.ejb3.Ejb3Deployment.resolvePersistenceUnitSupplier(Ejb3Deployment.java:720)
      at org.jboss.ejb3.EJBContainer.resolvePersistenceUnitSupplier(EJBContainer.java:1418)
      at org.jboss.injection.PersistenceUnitHandler.addPUDependency(PersistenceUnitHandler.java:125)
      ... 27 more
      03:14:39,376 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

      *** CONTEXTS IN ERROR: Name -> Error

      vfsfile:/D:/Workspace/Final%20Project/HR%20Module%20Final/Workspace/Application%20Server/jboss-5.0.0.GA-jdk6/jboss-5.0.0.GA/server/default/deploy/HR.ear/ -> java.lang.IllegalArgumentException: Can't find a persistence unit named 'HRPU' in AbstractVFSDeploymentContext@17659299{vfsfile:/D:/Workspace/Final%20Project/HR%20Module%20Final/Workspace/Application%20Server/jboss-5.0.0.GA-jdk6/jboss-5.0.0.GA/server/default/deploy/HR.ear/}


      03:14:39,407 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
      03:14:39,431 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
      03:14:39,439 INFO [ServerImpl] JBoss (Microcontainer) [5.0.0.GA (build: SVNTag=JBoss_5_0_0_GA date=200812042120)] Started in 56s:262ms



      code:
      My Bean:

      @Stateless
      public class OperationServiceBean implements OperationService {

      @PersistenceContext(unitName="HRPU")
      private EntityManager entityManager;

      @Override
      public Operation createOperation(Operation operation) {
      entityManager.persist(operation);
      return operation;
      }

      @Override
      public void removeOperation(Long id) {
      Operation operation = entityManager.find(Operation.class, id);
      if(operation != null) {
      entityManager.remove(operation);
      }
      }

      }



      persistance.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">

      <persistence-unit name="HRPU" transaction-type="JTA">
      <jta-data-source>java:/mySQLDS</jta-data-source>




      </persistence-unit>






        • 1. Failed to find PU
          omergillani

          I m really stuck! Waiting 4 smeone help

          • 2. Re: Plz help me asap!
            peterj

            Where did you place your persistence.xml in the HR.ear??

            • 3. Re: Plz help me asap!
              omergillani

              i have placed persistance.xml in META-INF directory of my ejb jar

              • 4. Re: Plz help me asap!
                omergillani

                iz there anyone who can help me

                • 5. Re: Plz help me asap!
                  brian.stansberry

                  A shot in the dark here. In several places you've said "persistance.xml". Did you name it that rather than "persistence.xml" -- "a" instead of "e"?

                  • 6. Re: Plz help me asap!
                    omergillani

                    well i spelled wrong here bt the name of file is right

                    persistence.xml

                    if i commen the code

                    @PersistenceContext(unitName="HRPU")
                    private EntityManager entityManager;

                    it does not throw the exception i guess my stateless bean loaded before
                    persistence unit

                    Am i right

                    If i m right iz there any soluction

                    • 7. Re: Plz help me asap!
                      peterj

                       

                      i have placed persistance.xml in META-INF directory of my ejb jar


                      Is this the same JAR file that hosts the entity beans?

                      • 8. Re: Plz help me asap!
                        omergillani

                        Yes this jar file also host my entities.
                        My exception is not about entities. they r load. I m getting exception about persistece unit

                        • 9. Re: Plz help me asap!
                          peterj

                          I know you are getting the error about the persistence unit and not the entity, but the reason you are getting the error is because the deployer found an entity bean, and based on that entity bean it is looking for the persistence unit. Both the entity, and the persistence unit, need to be in the same archive. For example, consider an entity bean located at:

                          org/some/package/name/MyEntity.class

                          then the relative path from MyEntity.class to the persistence unit must be ../../../../META-INF/persistence.xml. Or to put it another way, the JAR file should contain:

                          org/some/package/name/MyEntity.class
                          META-INF/persistence.xml

                          Also note that the location of the persistence.xml file has nothing to do with the client class that declares the EntityManager or the @PersistenceContext annotation. Now that I think of it, perhaps the client is getting deployed before the entity, and hence the persistence unit is not yet registered. What version of JBoss AS are you running? The problem with things getting deployed out of order is a known issue (or feature?) of JBoss AS 5.

                          • 10. Re: Plz help me asap!
                            omergillani

                            Well! I did lot of experiment with it

                            i moved the persistence.xml at HR.ear META-INF directory in this case I have got the exception on Entity class then i again moved my persistence.xml to the HREJB.jar META-INF directory

                            My code is working on the jboss4.2.2GA

                            Yes this is the exception about out of order

                            My EJB use persistence unit but persistence unit is not yet deployed. But tell me how can I specify that Persistence unit should deploy before the the EJB that is using persistence unit.

                            Thanks

                            • 11. Re: Plz help me asap!
                              jaikiran

                              Do this:

                              1) Post the entire console log (the one which you see on the console) including the exception stacktrace
                              2) Post the output of

                              jar -tf HR.ear

                              3) Post the code of your bean where you are injecting the @PersistenceContext (i know, you already did it once, but please post it again with whatever changes you have done).
                              4) Post the contents of your application.xml and jboss-app.xml (if you have one).

                              While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.

                              • 12. Re: Plz help me asap!
                                alrubinger
                                • 13. Re: Plz help me asap!
                                  omergillani

                                  Thanks Man

                                  I have got the problem. Actually i was using myeclipse for the development and for test deployment of my HR.ear by using myeclipse deploy option. MyEclipse deployer deploy HR.ear content two time one time in packaged archive and second time expended which was the problem for jboss.

                                  Issue resolved