1 Reply Latest reply on Jan 5, 2013 9:02 AM by Wolf-Dieter Fink

    I'm not able to access my message driven bean from remote server

    Gaurav Agrawal Newbie



      I have created a mdb, I'm able to access it If my client is in same ear with my mdb. but I try to access the mdb from the standalone java program it threw the exception NamingException. Please help me out.



      public class MDBClient {

                public static void main(String[] args) throws Exception {


                          String JBOSS_CONTEXT = "org.jboss.naming.remote.client.InitialContextFactory";

                          Properties props = new Properties();

                          props.put(Context.INITIAL_CONTEXT_FACTORY, JBOSS_CONTEXT);

                          props.put(Context.PROVIDER_URL, "remote://localhost:4447");

                          props.put(Context.SECURITY_PRINCIPAL, "admin2");

                          props.put(Context.SECURITY_CREDENTIALS, "admin123");

                          props.put("jboss.naming.client.ejb.context", true);

                          InitialContext ctx = new InitialContext(props);


                          QueueConnection cnn = null;

                          QueueSender sender = null;

                          QueueSession session = null;

                          Queue queue = (Queue) ctx.lookup("java:jboss/exported/jms/queue/test");

                          QueueConnectionFactory factory = (QueueConnectionFactory) ctx


                          cnn = factory.createQueueConnection();

                          session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);



                          TextMessage msg = session.createTextMessage("Hello World");



                          sender = session.createSender(queue);


                          System.out.println("Message sent successfully to remote queue.");







      package mdb;



      import javax.ejb.ActivationConfigProperty;

      import javax.ejb.MessageDriven;

      import javax.jms.JMSException;

      import javax.jms.Message;

      import javax.jms.MessageListener;

      import javax.jms.TextMessage;




      * Message-Driven Bean implementation class for: MyMessageDrivenBean



      @MessageDriven(activationConfig = {

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

                          @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/test") }, name="MyMDB")

      public class MyMessageDrivenBean implements MessageListener {




                 * Default constructor.


                public MyMessageDrivenBean() {

                          // TODO Auto-generated constructor stub





                 * @see MessageListener#onMessage(Message)


                public void onMessage(Message message) {

                          // TODO Auto-generated method stub

                          TextMessage msg = (TextMessage) message;

                          try {

                                    System.out.println("Message recievend ######### : " + msg.getText()) ;

                          } catch (JMSException e) {

                                    // TODO Auto-generated catch block










                          <jms-queue name="testQueue">

                              <entry name="queue/test"/>

                              <entry name="java:jboss/exported/jms/queue/test"/>


                          <jms-topic name="testTopic">

                              <entry name="topic/test"/>

                              <entry name="java:jboss/exported/jms/topic/test"/>




      Please help me out.