2 Replies Latest reply on Nov 20, 2002 7:14 PM by koltar

    MDB is not listening to Queue appears to not get deployed, H

    koltar Newbie

      ejb-jar.xml (Where is this suppose to go?)
      jboss.xml (Where is this suppose to go?)

      I tried placing the xmls in server/default/deploy also tried placing in the META-INF in my test.ear file.

      The JSP code runs through without an error but the Message Bean never fires off a method. What am I doing wrong?

      The MDB is based on the bought JBoss AdminDeveloper Manual.

      JSP Client Content:
      System.out.println("Initializing Client Message...");
      InitialContext context = new InitialContext();
      QueueConnectionFactory queueFactory = (QueueConnectionFactory)context.lookup("ConnectionFactory");
      QueueConnection queueConnection = queueFactory.createQueueConnection();
      QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue queue = (Queue)context.lookup("queue/loginAuditQueue");
      System.out.println("Found queue/loginAuditQueue...");
      QueueSender queueSender = queueSession.createSender(queue);
      TextMessage message = queueSession.createTextMessage();
      message.setText("Login: TESTING");
      queueSender.send(queue, message);
      System.out.println("Message sent to Queue...");
      queueSession.close();
      queueConnection.close();
      System.out.println("Connections to Queue Closed");

      MDB Contents:
      package com.test.message;
      import javax.ejb.MessageDrivenBean;
      import javax.ejb.MessageDrivenContext;
      import javax.ejb.EJBException;
      import javax.jms.JMSException;
      import javax.jms.Message;
      import javax.jms.MessageListener;
      import javax.jms.Queue;
      import javax.jms.QueueConnection;
      import javax.jms.QueueConnectionFactory;
      import javax.jms.QueueSender;
      import javax.jms.QueueSession;
      import javax.jms.TextMessage;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      public class LoginAuditMDB {
      private MessageDrivenContext ctx = null;
      private QueueConnection conn;
      private QueueSession session;
      public LoginAuditMDB() {
      System.out.println("LoginAuditMDB.constructor1()["+hashCode()+"]");
      }
      public void setMessageDrivenContext(MessageDrivenContext ctx) {
      this.ctx = ctx;
      System.out.println("LoginAuditMDB.setMessageDrivenContext()["+hashCode()+"]");
      }
      public void ejbCreate() {
      System.out.println("LoginAudit.ejbCreate()["+hashCode()+"]");
      try {
      setupPTP();
      } catch(Exception e) {
      throw new EJBException("Failed to init LoginAuditMDB"+e.getMessage());
      }
      }
      public void ejbRemove() {
      System.out.println("LoginAuditMDB.ejbRemove()["+hashCode()+"]");
      ctx = null;
      try {
      if( session != null ) session.close();
      if( conn != null ) conn.close();
      } catch(JMSException e) {
      e.printStackTrace();
      }
      }
      public void onMessage(Message msg) {
      System.out.println("LoginAuditMDB.onMessage()["+hashCode()+"]");
      }
      private void setupPTP() throws JMSException, NamingException {
      InitialContext iniCtx = new InitialContext();
      Object tmp = iniCtx.lookup("ConnectionFactory");
      QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
      conn = qcf.createQueueConnection();
      session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
      conn.start();
      }
      }



      ejb-jar.xml contents:
      <?xml version="1.0"?>
      <!DOCTYPE ejb-jar
      PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
      "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar>
      <enterprise-beans>
      <message-driven>
      <ejb-name>LoginAuditMDB</ejb-name>
      <ejb-class>com.test.message.LoginAuditMDB</ejb-class>
      <transaction-type>Container</transaction-type>
      <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
      <message-driven-destination>
      <destination-type>javax.jms.Queue</destination-type>
      </message-driven-destination>
      <resource-ref>
      Default QueueFactory
      <res-ref-name>jms/ConnectionFactory</res-ref-name>
      <res-auth>Container</res-auth>
      </resource-ref>
      </message-driven>
      </enterprise-beans>
      </ejb-jar>

      jboss.xml contents:
      <?xml version"1.0"?>

      <enterprise-beans>
      <message-driven>
      <ejb-name>LoginAuditMDB</ejb-name>
      <destination-jndi-name>queue/loginAuditQueue</destination-jndi-name>
      <resource-ref>
      <res-ref-name>jms/ConnectionFactory</res-ref-name>
      <jndi-name>QueueConnectionFactory</jndi-name>
      </resource-ref>
      </message-driven>
      </enterprise-beans>


      META-INF/application.xml
      <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">


      <display-name>Test</display-name>

      ejb-test.jar



      <web-uri>test.war</web-uri>
      <context-root>test</context-root>