1 Reply Latest reply on Feb 10, 2012 10:07 AM by Denys Myxin

    Error deploying EJB on JBoss 6 using @Resource annotation and jndi.properties

    rosanero4ever Newbie

      I'm using netbeans 7 and JBoss 6 and I'm looking for a solution in these days about the error pasted below when I deploy mi EJB 3 bean using @Resource annotation.

      It seems an error caused by a bad position of the jndi.properties in the ear structure (if you want you can see the attachment containing my netbeans project). I put this file in the classpath of the project, i.e. the src folder. I also used the conf folder of the ear but the problem still occurs.

      I hope anyone can help me to understand the right way.

      Thanks in advance

       

       

      The EJB code (taken from the book "EJB in Action") and the error are the following:

       

       

       

        @Stateless public class PlaceOrderBean implements PlaceOrderBeanLocal

          {

       

       

          @Resource(name = "jms/QueueConnectionFactory")

          private ConnectionFactory connectionFactory; 

       

       

       

          private Long bidderId;

          private List<Longitems;

          private ShippingInfo shippingInfo;

          private BillingInfo billingInfo;

       

       

          public PlaceOrderBean() {

              items = new ArrayList<Long>();

          }

       

       

       

       

          private void billOrder(Order order) {

              try {

                  Connection connection = connectionFactory.createConnection();

                  Session session = connection.createSession(false,

                          Session.AUTO_ACKNOWLEDGE);

                  MessageProducer producer = session.createProducer(billingQueue);

                  ObjectMessage message = session.createObjectMessage();

                  message.setObject(order);

                  producer.send(message);

                  producer.close();

                  session.close();

                  connection.close();

              } catch (Exception e) {

                  e.printStackTrace();

              }

       

          }

       

       

       

       

          @Remove

          public Long confirmOrder() {

              Order order = new Order();

              order.setBidderId(bidderId);

              order.setItems(items);

              order.setShippingInfo(shippingInfo);

              order.setBillingInfo(billingInfo);

              saveOrder(order);

              billOrder(order);

              return order.getOrderId();

          }

       

       

       

          /* OTHER METHODS */

       

       

          }

       

       

       

      The error is :

       

       

       

      16:03:23,296 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error

       

       

          installing to Real: name=vfs:///D:/jboss6/server/default/deploy/prova2.ear state=PreReal mode=Manual requiredState=Real: org.jboss.deployers.spi.DeploymentException: Error during deploy: org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.PlaceOrderBean

                    at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:185) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1832) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1550) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1571) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1603) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1491) [:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.0.GA]

                    at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.0.0.Final]

                    at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.deploy(HDScanner.java:240) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.complete(HDScanner.java:192) [:0.2.2]

                    at org.jboss.profileservice.management.TwoPCActionWrapper.doComplete(TwoPCActionWrapper.java:57) [:0.2.2]

                    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.complete(AbstractTwoPhaseModificationAction.java:74) [:0.2.2]

                    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.prepare(AbstractTwoPhaseModificationAction.java:95) [:0.2.2]

                    at org.jboss.profileservice.management.ModificationSession.prepare(ModificationSession.java:87) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.internalPerfom(AbstractActionController.java:234) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.performWrite(AbstractActionController.java:213) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:150) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:135) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.scan(HDScanner.java:146) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.run(HDScanner.java:90) [:0.2.2]

                    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [:1.7.0]

                    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) [:1.7.0]

                    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) [:1.7.0]

                    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [:1.7.0]

                    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [:1.7.0]

                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0]

                    at java.lang.Thread.run(Thread.java:722) [:1.7.0]

          Caused by: java.lang.RuntimeException: Neither any mapped-name/lookup/jndi-name specified nor any ResourceProvider could process resource-ref named env/jms/QueueConnectionFactory of type javax.jms.ConnectionFactory

                    at org.jboss.switchboard.mc.resource.provider.ResourceRefResourceProviderDelegator.provide(ResourceRefResourceProviderDelegator.java:125) [:1.0.0-alpha-15]

                    at org.jboss.switchboard.mc.resource.provider.ResourceRefResourceProviderDelegator.provide(ResourceRefResourceProviderDelegator.java:44) [:1.0.0-alpha-15]

                    at org.jboss.switchboard.mc.JndiEnvironmentProcessor.process(JndiEnvironmentProcessor.java:68) [:1.0.0-alpha-15]

                    at org.jboss.switchboard.mc.deployer.AbstractSwitchBoardDeployer.process(AbstractSwitchBoardDeployer.java:119) [:1.0.0-alpha-15]

                    at org.jboss.switchboard.mc.deployer.EJBEnvironmentSwitchBoardDeployer.internalDeploy(EJBEnvironmentSwitchBoardDeployer.java:87) [:1.0.0-alpha-15]

                    at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.GA]

                    ... 38 more

       

          16:03:23,484 WARN  [org.jboss.profileservice.deployment.hotdeploy.HDScanner] Scan failed: org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

       

          *** DEPLOYMENTS IN ERROR: Name -> Error

       

          vfs:///D:/jboss6/server/default/deploy/prova2.ear -> org.jboss.deployers.spi.DeploymentException: Error during deploy: org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData.PlaceOrderBean

       

       

          DEPLOYMENTS IN ERROR:

            Deployment "vfs:///D:/jboss6/server/default/deploy/prova2.ear" is in error due to the following reason(s): java.lang.RuntimeException: Neither any mapped-name/lookup/jndi-name specified nor any ResourceProvider could process resource-ref named env/jms/QueueConnectionFactory of type javax.jms.ConnectionFactory

       

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1370) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:1316) [:2.2.0.GA]

                    at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:968) [:2.2.0.GA]

                    at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.checkComplete(MainDeployerPlugin.java:82) [:6.0.0.Final]

                    at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.checkComplete(ProfileControllerContext.java:138) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.deploy(HDScanner.java:246) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner$HDScanAction.complete(HDScanner.java:192) [:0.2.2]

                    at org.jboss.profileservice.management.TwoPCActionWrapper.doComplete(TwoPCActionWrapper.java:57) [:0.2.2]

                    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.complete(AbstractTwoPhaseModificationAction.java:74) [:0.2.2]

                    at org.jboss.profileservice.management.actions.AbstractTwoPhaseModificationAction.prepare(AbstractTwoPhaseModificationAction.java:95) [:0.2.2]

                    at org.jboss.profileservice.management.ModificationSession.prepare(ModificationSession.java:87) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.internalPerfom(AbstractActionController.java:234) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.performWrite(AbstractActionController.java:213) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:150) [:0.2.2]

                    at org.jboss.profileservice.management.AbstractActionController.perform(AbstractActionController.java:135) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.scan(HDScanner.java:146) [:0.2.2]

                    at org.jboss.profileservice.deployment.hotdeploy.HDScanner.run(HDScanner.java:90) [:0.2.2]

                    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [:1.7.0]

                    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351) [:1.7.0]

                    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178) [:1.7.0]

                    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [:1.7.0]

                    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [:1.7.0]

                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0]

                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0]

                    at java.lang.Thread.run(Thread.java:722) [:1.7.0]

       

      I edited my post attaching a zip file containing my netbeans project.

        • 1. Re: Error deploying EJB on JBoss 6 using @Resource annotation and jndi.properties
          Denys Myxin Newbie

          Hello.

          Likely you need to open file hortnetq-jms.xml in /jboss/<profile>/deploy/hortnetq dir and add lines:

          <connection-factory name="QueueConnectionFactory" signature="queue">

                  <xa>true</xa>

                  <connectors>

                     <connector-ref connector-name="in-vm"/>

                  </connectors>

                  <entries>

                      <entry name="/QueueConnectionFactory"/>          

                  </entries>

              </connection-factory>

          <queue name="OrderBillingQueue">

                <entry name="/jms/OrderBillingQueue"/>

             </queue>

          Then open file PlaceOrderBean and change Resource attributes:

              @Resource(name="QueueConnectionFactory", mappedName="/QueueConnectionFactory")

              private ConnectionFactory connectionFactory;

           

              @Resource(name="/jms/OrderBillingQueue", mappedName = "/jms/OrderBillingQueue")

              private Queue billingQueue;

           

          Open file OrderBillingMDb and changes lines:

          @MessageDriven(activationConfig = {

                  @ActivationConfigProperty(propertyName = "destination", propertyValue = "/jms/OrderBillingQueue"),

                  @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })

          public class OrderBillingMDB implements MessageListener {

          ....

          Please take attention about jndi name queue and connection factory.

          Best regards, Denys.