[jboss-user] [Beginners Corner] - Looking up MessageDrivenBean/MessageListener

OCGabriel do-not-reply at jboss.com
Wed Sep 13 21:52:25 EDT 2006


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 at 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 at 24345503,plugin=invoker,service=EJB not found: javax.management.InstanceNotFoundException: jbos
  | s.j2ee:binding=message-driven-bean,jndiName=local/ejb/BatchProcessorBean at 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 at 24345503,plugin=invoker,service=EJB not found: javax.management.InstanceNotFoundException: jboss.j2ee:binding=message-driven-bean,j
  | ndiName=local/ejb/BatchProcessorBean at 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 ?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971446#3971446

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971446



More information about the jboss-user mailing list