2 Replies Latest reply on Oct 15, 2001 2:47 PM by Papick

    SpyJMSException: Cannot get a client ID

    Papick Newbie

      hi,

      i was trying to setup the simple hello mdb bean mentioned in the jboss documentation.
      when starting the publisher client i get the follwing error:
      org.jboss.mq.SpyJMSException;
      Cannot get a client ID: Cannot assign requested address: connect

      here is my code:
      --------------------------------------------- jboss.xml
      ---------------------------
      ---
      --
      <?xml version="1.0"?>

      <enterprise-beans>
      <message-driven>
      <ejb-name>SimpleMessageBean</ejb-name>
      <configuration-name>Standard Message Driven Bean</configuration-name>
      <destination-jndi-name>topic/testTopic</destination-jndi-name>
      </message-driven>
      false
      </enterprise-beans>


      ------------------------------------------- ejb-jar.xml
      ---------------------------
      ---
      --
      <?xml version="1.0"?>
      <ejb-jar>
      <enterprise-beans>
      <message-driven>
      <ejb-name>SimpleMessageBean</ejb-name>
      <ejb-class>ejb.SimpleMessageBeanEJB</ejb-class>
      <message-selector></message-selector>
      <transaction-type>Container</transaction-type>
      <message-driven-destination>
      <destination-type>javax.jms.Topic</destination-type>
      <subscription-durability>NonDurable</subscription-durability>
      </message-driven-destination>
      </message-driven>
      </enterprise-beans>
      <assembly-descriptor>
      <container-transaction>

      <ejb-name>SimpleMessageBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>

      ----------------------------- SimpleMessageBeanEJB.java
      ---------------------------
      ---
      --
      package ejb;

      import javax.ejb.MessageDrivenBean;
      import javax.ejb.MessageDrivenContext;
      import javax.ejb.EJBException;
      import javax.ejb.CreateException;

      import javax.naming.InitialContext;
      import javax.naming.Context;

      import javax.jms.MessageListener;
      import javax.jms.Message;
      import javax.jms.TextMessage;

      public class SimpleMessageBeanEJB implements MessageDrivenBean, MessageListener {

      private MessageDrivenContext ctx = null;

      public void setMessageDrivenContext(MessageDrivenContext ctx)
      throws EJBException
      {
      this.ctx = ctx;
      }

      public void ejbCreate() throws CreateException
      { }

      public void ejbRemove()
      {
      ctx=null;
      }

      public void onMessage(Message message)
      {

      System.out.println("HelloListen got message " + message.toString());

      }

      }

      --------------------------------------------- Main.java
      ---------------------------
      ---
      --
      package test;
      import javax.naming.*;

      import javax.jms.*;

      public class Main
      {
      public static void main(String arg[]) {

      try
      {
      // Get access to JNDI
      Context context = new InitialContext();

      // Lookup the managed connection factory for a topic
      TopicConnectionFactory topicFactory =
      (TopicConnectionFactory)context.lookup("TopicConnectionFactory");

      // Create a connection to the JMS provider
      TopicConnection topicConnection = topicFactory.createTopicConnection();

      // Creat a topic session
      TopicSession session = topicConnection.createTopicSession(
      // No transaction
      false,
      // Auto ack
      Session.AUTO_ACKNOWLEDGE);

      // Lookup the destination you want to publish to
      Topic topic = (Topic)context.lookup("topic/testTopic");

      // Create a publisher
      TopicPublisher pub = session.createPublisher(topic);

      // Create a message
      TextMessage message = session.createTextMessage();
      message.setText("Hello World!");

      // Publish the message
      pub.publish(topic, message);

      // Close the stuff
      session.close();
      topicConnection.close();
      } catch (Exception e)
      {
      e.printStackTrace();
      }
      }
      }