2 Replies Latest reply on Sep 14, 2006 6:45 PM by ocgabriel

    Looking up MessageDrivenBean/MessageListener

    ocgabriel

      Hi,

      Firstly, i am using JBoss 3.2.7 (this cant be changed).

      I have the following scenario and im stuck for ideas on what is going on and why its failing to lookup as you will see.

      I have a queue called: BatchProcessorQueue
      (The queue works fine with the unit tests i have in place)

      I have an MDB with the following description:

      package mdb;
      
      //imports
      
      /**
       * @ejb.bean
       * name="ejb/BatchProcessorBean"
       * display-name="BatchProcessorBean"
       * acknowledge-mode="Auto-acknowledge"
       * destination-type="javax.jms.Queue"
       * subscription-durability="Durable"
       *
       * @jboss.destination-jndi-name
       * name="queue/BatchProcessorQueue"
       */
      public class BatchProcessorBean implements MessageDrivenBean, MessageListener
      {
       // non relevant code
      }


      When this MDB is loaded into JBoss, the entry i see in the JMX console is:

      jboss.j2ee
      binding=message-driven-bean,jndiName=local/ejb/BatchProcessorBean@24345503,plugin=invoker,service=EJB


      In another bean i have the following code where i actually try to locate the MDB but it isnt able to locate the MDB and every combination ive tried for the object name isnt working.

      JMSContainerInvokerMBean invoker = null;
      
      try
      {
       ObjectName configObjName = new ObjectName(
       "jboss.j2ee:name=local/ejb/BatchProcessorBean"
       );
      
       invoker = (JMSContainerInvokerMBean) MBeanProxy.get(
       JMSContainerInvokerMBean.class,
       configObjName,
       MBeanHelper.getMBeanServer() );
      }
      catch ( Exception e )
      {
       log.warn( "failed to obtain a valid service configuration MBean, using default, " + e.getMessage() );
       e.printStackTrace();
      }
      
      if(invoker != null)
      {
       try
       {
       log.info("Stopping the MBean");
       invoker.stop();
       log.info("Setting MBean to size of " + size);
       invoker.setMaxPoolSize(size);
       log.info("Starting the MBean");
       invoker.start();
       return true;
       }
       catch (Exception e)
       {
       log.warn("Failed to restart the BatchProcessorBean MBean");
       e.printStackTrace();
       }
      }


      Having tried countless combinations for the lookup but the error i get is this:
      01:44:09,111 WARN [AdapterBean] failed to obtain a valid service configuration MBean, using default, Object name jboss.j2ee:binding=message-driven-bean,jndiName=local/ejb/BatchProcessorBean@24345503,plugin=invoker,service=EJB not found: javax.management.InstanceNotFoundException: jbos
      s.j2ee:binding=message-driven-bean,jndiName=local/ejb/BatchProcessorBean@24345503,plugin=invoker,service=EJB is not registered.
      01:44:09,111 INFO [STDOUT] org.jboss.mx.util.MBeanProxyCreationException: Object name jboss.j2ee:binding=message-driven-bean,jndiName=local/ejb/BatchProcessorBean@24345503,plugin=invoker,service=EJB not found: javax.management.InstanceNotFoundException: jboss.j2ee:binding=message-driven-bean,j
      ndiName=local/ejb/BatchProcessorBean@24345503,plugin=invoker,service=EJB is not registered.
      01:44:09,142 INFO [STDOUT] at org.jboss.mx.util.JMXInvocationHandler.<init>(JMXInvocationHandler.java:150)
      01:44:09,142 INFO [STDOUT] at org.jboss.mx.util.MBeanProxy.get(MBeanProxy.java:76)
      01:44:09,142 INFO [STDOUT] at org.jboss.mx.util.MBeanProxy.get(MBeanProxy.java:64)
      .
      .
      .
      .
      


      Am i missing something somewhere in regards to configuration of the MDB? Does anyone have a similar sort of example i can refer to ? As u will have noticed im trying to restart the target mean that im trying to lookup.

      Am i trying to do the impossible here ? Ive tried to follow this:
      http://wiki.jboss.org/wiki/Wiki.jsp?page=HowCanAnEJBCallAnMBean
      But i dont think it works so well in this situation, or am i missing something from this guide in my implementation ?