3 Replies Latest reply on Dec 28, 2011 6:01 AM by aupres

    can't find message-driven bean..

    aupres

      I make codes Message-Driven Bean on JBoss 7 and Eclipse Indigo.

      Architecture is

       

      JMSTestEAR

              |

              |--JMSTestEJB (contains Message-Driven Bean)

              |

              |--JMSTestWeb (contains jsp which calls Message-Bean)

       

      And Codes are

       

      ==================Message Driven Bean =====================

       

      @MessageDriven(
        activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue") })
      public class MDBean implements MessageListener {

          public MDBean() {
              // TODO Auto-generated constructor stub
          }

          public void onMessage(Message message) {
              // TODO Auto-generated method stub
           TextMessage m = (TextMessage) message;
           try {
              System.out.println(m.getText());
           } catch (JMSException e) {
             e.getMessage();
           }
         }

      }

      =============== JSP ============

      ........

      <body>

      <%

      try {

          Context ctx = new InitialContext();

          Queue queue = (Queue) ctx.lookup("queue/testQueue"); //throws Exception

          QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");

          QueueConnection conn = qcf.createQueueConnection();

          QueueSession qs = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);

          TextMessage msg = qs.createTextMessage("Hi !");

          QueueSender sender = qs.createSender(queue);

          sender.send(msg);

      } catch (Exception e) {

          out.println(e.getMessage());

      }

      %>

      </body>

      ....

       

      Deploymemts are successful. ear , jar and war are deployed. But JSP throws exception below:

         

         queue/testQueue -- service jboss.naming.context.java.queue.testQueue

       

      Is ejb3 jar deployment succeeded? or do i miss any process in deploying message-driven bean?

      I need your advice! Thanks in advance..

       

      Best regards.

        • 1. Re: can't find message-driven bean..
          jaikiran

          How have you deployed the queue?

          • 2. Re: can't find message-driven bean..
            aupres

            you are absolutely right! After deplying the queue, message service works well! Thanks

            • 3. Re: can't find message-driven bean..
              aupres

              I deployed the queue on jboss 7. On console deployment was shown like below,

               

              [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) trying to deploy queue jms.queue.testQueue
              19:24:44,119 INFO  [org.jboss.as.messaging.jms.AS7BindingRegistry] (MSC service thread 1-2) Bound messaging object to jndi name java:/queue/testQueue
              19:24:44,134 INFO  [org.jboss.as.messaging.jms.AS7BindingRegistry] (MSC service thread 1-1) Bound messaging object to jndi name java:/ConnectionFactory
              19:24:44,150 INFO  [org.jboss.as.messaging.jms.AS7BindingRegistry] (MSC service thread 1-4) Bound messaging object to jndi name java:/RemoteConnectionFactory

               

              But this time message-bean shows no message.No exception either!

              Kindly inform me what is wrong this time.