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

    Plz help me asap!

    Omer Gillani Newbie

      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>