5 Replies Latest reply on Feb 10, 2009 12:33 PM by Jose Alvarez de Lara

    javax.naming.NameNotFoundException: mdbtest not bound

    Jose Alvarez de Lara Novice

      Hello,

      I am developing an EJB3 MDB in Eclipse Ganymede RS1
      against JBoss 4.2.2 GA.

      At deployment time I get the following exception,

      13:18:28,493 INFO [EARDeployer] Init J2EE application: file:/C:/jboss-4.2.2.GA/server/default/deploy/ProducerConsumerClientEAR.ear
      13:18:28,805 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.mdb.ConsumerContainer
      13:18:28,805 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=ProducerConsumerClientEAR.ear,jar=ConsumerMDB.jar,name=QueueTestConsumer,service=EJB3 with dependencies:
      13:18:29,007 INFO [EJBContainer] STARTED EJB: test.mdb.QueueTestConsumer ejbName: QueueTestConsumer
      13:18:29,007 WARN [MessagingContainer] Could not find the queue destination-jndi-name=queue/mdbtest
      13:18:29,007 WARN [MessagingContainer] destination not found: queue/mdbtest reason: javax.naming.NameNotFoundException: mdbtest not bound
      13:18:29,007 WARN [MessagingContainer] creating a new temporary destination: queue/mdbtest
      13:18:29,023 INFO [mdbtest] Bound to JNDI name: queue/mdbtest
      13:18:29,117 INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.2.2.GA/server/default/tmp/deploy/tmp5377057139345978599ProducerConsumerClientEAR.ear-contents/ConsumerMDB.jar
      13:18:29,148 INFO [EARDeployer] Started J2EE application: file:/C:/jboss-4.2.2.GA/server/default/deploy/ProducerConsumerClientEAR.ear
      


      This is my code,

      #1 The producer
      package test.mdb;
      
      import org.jboss.annotation.ejb.Producer;
      
      @Producer
      public interface QueueTestRemote {
       public void method1(String msg, int num);
      }
      


      #2 The consumer (the bean)
      package test.mdb;
      
      import javax.ejb.ActivationConfigProperty;
      import org.jboss.annotation.ejb.Consumer;
      
      /**
       * Message-Driven Bean implementation class for: QueueTestConsumer
       *
       */
      @Consumer(
       activationConfig = {
       @ActivationConfigProperty(
       propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
       @ActivationConfigProperty(
       propertyName="destination", propertyValue="queue/mdbtest")
       })
      public class QueueTestConsumer implements QueueTestRemote {
      
       /**
       * Default constructor.
       */
       public QueueTestConsumer() {
       // TODO Auto-generated constructor stub
       }
      
       @Override
       public void method1(String msg, int num) {
       // TODO Auto-generated method stub
       System.out.println("method1(" + msg + ", " + num + ")");
       }
      
      }
      


      #3 And the client
      package test.mdb;
      
      import javax.naming.InitialContext;
      import org.jboss.ejb3.mdb.ProducerObject;
      import org.jboss.ejb3.mdb.ProducerManager;
      
      public class Client {
      
       /**
       * @param args
       */
       public static void main(String[] args) throws Exception
       {
       // TODO Auto-generated method stub
       InitialContext ctx = new InitialContext();
       QueueTestRemote tester = (QueueTestRemote)ctx.lookup(QueueTestRemote.class.getName());
      
       ProducerObject po = (ProducerObject)tester;
       ProducerManager manager = (ProducerManager)po.getProducerManager();
      
       manager.connect(); // internally create a JMS connection
       try
       {
       tester.method1("hello world", 55);
       }
       finally
       {
       manager.close(); // clean up the JMS connection
       }
       }
      }
      



      And in runtime I get another exception,
      Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
       at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
       at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
       at javax.naming.InitialContext.lookup(Unknown Source)
       at test.mdb.Client.main(Client.java:16)
      


      And I do not know what is going wrong.

      Thanks in advance,
      Jose Alvarez de Lara