3 Replies Latest reply on Aug 21, 2002 12:19 PM by Lars-Inge Tønnessen

    Cannot subscribe to this Destination

    Lars-Inge Tønnessen Newbie

      Hello.

      I'm working my way through the examples (JMS) in the pdf-file for the JBoss 2.4.x. I can't get any of them to work with the JBoss 3.0.0 release.

      The following is from the client test without a bean (the first example). It sends a message, and receives it.

      This line is the problem:
      QueueReceiver recv = session.createReceiver( que );



      This is the exception:
      X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      Begin sendRecvAsync
      It gets here.
      org.jboss.mq.SpyJMSException: Cannot subscribe to this Destination: org.jboss.mq.Subscription; local class incompatible: stream classdesc serialVersionUID = 1875870388683297285, local class serialVersionUID = -4045603824932803577
      at org.jboss.mq.Connection.addConsumer(Connection.java:974)
      at org.jboss.mq.SpySession.addConsumer(SpySession.java:414)
      at org.jboss.mq.SpyQueueSession.createReceiver(SpyQueueSession.java:97)
      at klient.klient.sendRecvAsync(klient.java:92)
      at klient.klient.main(klient.java:124)
      linked exception is:
      java.io.InvalidClassException: org.jboss.mq.Subscription; local class incompatible: stream classdesc serialVersionUID = 1875870388683297285, local class serialVersionUID = -4045603824932803577
      at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:454)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1511)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1425)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1616)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
      at org.jboss.mq.il.oil.OILServerILService$Client.run(OILServerILService.java:287)
      at java.lang.Thread.run(Thread.java:536)
      linked exception is:
      java.io.InvalidClassException: org.jboss.mq.Subscription; local class incompatible: stream classdesc serialVersionUID = 1875870388683297285, local class serialVersionUID = -4045603824932803577
      at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:454)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1511)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1425)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1616)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1264)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
      at org.jboss.mq.il.oil.OILServerILService$Client.run(OILServerILService.java:287)
      at java.lang.Thread.run(Thread.java:536)
      X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X






      Here is the code:

      package klient;

      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      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.QueueReceiver;
      import javax.jms.QueueSender;
      import javax.jms.QueueSession;
      import javax.jms.TextMessage;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import java.util.Properties;
      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X



      public class klient {

      QueueConnection conn;
      QueueSession session;
      Queue que;



      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      private class messIn implements MessageListener {
      public void onMessage( Message msg ) {
      TextMessage tm = (TextMessage) msg;
      try {
      System.out.println("OnMessage:"+tm.getText() );
      } catch ( Throwable t ) { t.printStackTrace(); }
      }
      }
      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X






      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      public void setupPTP() throws JMSException, NamingException {
      Properties env;
      env = new Properties();
      env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      env.setProperty("java.naming.provider.url", "localhost:1099");
      env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
      InitialContext iniCtx = new InitialContext( env );


      Object tmp = iniCtx.lookup("java:/ConnectionFactory");
      // Object tmp = iniCtx.lookup("java:/QueueConnectionFactory");

      QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
      conn = qcf.createQueueConnection(); //"guest", "guest");
      que = (Queue) iniCtx.lookup("java:/queue/testQueue");
      session = conn.createQueueSession( false, QueueSession.AUTO_ACKNOWLEDGE );
      conn.start();
      }
      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X




      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      public void sendRecvAsync( String text ) throws JMSException, NamingException {
      System.out.println("Begin sendRecvAsync");
      setupPTP();

      System.out.println("It gets here.");

      QueueReceiver recv = session.createReceiver( que );

      System.out.println("Does NOT get here.");

      recv.setMessageListener( new messIn() );
      QueueSender send = session.createSender( que );
      TextMessage tm = session.createTextMessage( text );
      send.send( tm );
      System.out.println("Message sent");
      send.close();
      System.out.println("End sendRecvAsync");
      }
      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X




      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      public void stop() throws JMSException {
      conn.stop();
      session.close();
      conn.close();
      }
      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X




      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      public static void main(String[] args) {
      try {
      klient client = new klient();
      client.sendRecvAsync(" - HELLO - ");
      client.stop();
      } catch ( Exception e ) { e.printStackTrace(); }
      System.exit(0);
      }
      // X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X=--=X
      }


      The jbossmq-service.xml file:

      <?xml version="1.0" encoding="UTF-8"?>

      <!-- $Id: jbossmq-service.xml,v 1.1.2.3 2002/05/09 04:25:10 chirino Exp $ -->



      <!-- ==================================================================== -->
      <!-- JBossMQ -->
      <!-- ==================================================================== -->


      <!-- ==================================================================== -->
      <!-- Invocation Layers -->
      <!-- ==================================================================== -->
      <!--
      | InvocationLayers are the different transport methods that can
      | be used to access the server.
      -->


      <depends optional-attribute-name="Invoker">jboss.mq:service=Invoker
      java:/ConnectionFactory
      java:/XAConnectionFactory
      0



      <depends optional-attribute-name="Invoker">jboss.mq:service=Invoker
      RMIConnectionFactory
      RMIXAConnectionFactory
      60000



      <depends optional-attribute-name="Invoker">jboss.mq:service=Invoker
      ConnectionFactory
      XAConnectionFactory
      8090
      60000
      true



      <depends optional-attribute-name="Invoker">jboss.mq:service=Invoker
      UILConnectionFactory
      UILXAConnectionFactory
      8091
      60000
      true


      <!-- ==================================================================== -->
      <!-- JBossMQ Interceptor chain configuration -->
      <!-- ==================================================================== -->
      <!-- To tune performance, you can have the Invoker skip over the TracingInterceptor -->
      <!-- and/or the SecurityManager, but then you loose the ability to trace and/or enforce security. -->

      <depends optional-attribute-name="NextInterceptor">jboss.mq:service=TracingInterceptor



      org.jboss.mq.server.TracingInterceptor
      <depends optional-attribute-name="NextInterceptor">jboss.mq:service=SecurityManager



      <depends optional-attribute-name="NextInterceptor">jboss.mq:service=DestinationManager



      <depends optional-attribute-name="PersistenceManager">jboss.mq:service=PersistenceManager
      <depends optional-attribute-name="StateManager">jboss.mq:service=StateManager


      <!--
      | The MessageCache decides where to put JBossMQ message that
      | are sitting around waiting to be consumed by a client.
      |
      | The memory marks are in Megabytes. Once the JVM memory usage hits
      | the high memory mark, the old messages in the cache will start getting
      | stored in the DataDirectory. As memory usage gets closer to the
      | Max memory mark, the amount of message kept in the memory cache aproaches 0.
      -->

      500
      600
      <depends optional-attribute-name="CacheStore">jboss.mq:service=CacheStore


      <!--
      | The CacheStore decides where to store JBossMQ message that
      | that the MessageCache has decided to move in secondary storage.
      -->

      tmp/jbossmq


      <!--
      | The StateManager is used to keep JMS persistent state data.
      | For example: what durable subscriptions are active.
      -->

      <!-- This file is pulled from the configuration URL of the server -->
      jbossmq-state.xml


      <!-- The PersistenceManager is used to store messages to disk. -->

      db/jbossmq/file
      <depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache


      <!--
      | The jdbc2 PersistenceManager is the new improved JDBC implementation.
      | This implementation allows you to control how messages are stored in
      | the database.
      |
      | Use this PM if you want the reliablity a relational database can offer
      | you. The default configuration is known to work with hsqldb, other databases
      | will requrie teaking of the SqlProperties.
      -->
      <!--

      <depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache
      <depends optional-attribute-name="DataSource">jboss.jca:service=LocalTxDS,name=hsqldbDS
      jboss.jca:service=LocalTxCM,name=hsqldbDS

      BLOB_TYPE=OBJECT_BLOB
      INSERT_TX = INSERT INTO JMS_TRANSACTIONS (TXID) values(?)
      INSERT_MESSAGE = INSERT INTO JMS_MESSAGES (MESSAGEID, DESTINATION, MESSAGEBLOB, TXID, TXOP) VALUES(?,?,?,?,?)
      SELECT_ALL_UNCOMMITED_TXS = SELECT TXID FROM JMS_TRANSACTIONS
      SELECT_MAX_TX = SELECT MAX(TXID) FROM JMS_MESSAGES
      SELECT_MESSAGES_IN_DEST = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE DESTINATION=?
      SELECT_MESSAGE = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=?
      MARK_MESSAGE = UPDATE JMS_MESSAGES SET (TXID, TXOP) VALUES(?,?) WHERE MESSAGEID=? AND DESTINATION=?
      DELETE_ALL_MESSAGE_WITH_TX = DELETE FROM JMS_MESSAGES WHERE TXID=?
      DELETE_TX = DELETE FROM JMS_TRANSACTIONS WHERE TXID = ?
      DELETE_MARKED_MESSAGES = DELETE FROM JMS_MESSAGES WHERE TXID=? AND TXOP=?
      DELETE_MESSAGE = DELETE FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=?
      CREATE_MESSAGE_TABLE = CREATE TABLE JMS_MESSAGES ( MESSAGEID INTEGER NOT NULL, \
      DESTINATION VARCHAR(50) NOT NULL, TXID INTEGER, TXOP CHAR(1), \
      MESSAGEBLOB OBJECT, PRIMARY KEY (MESSAGEID, DESTINATION) )
      CREATE_TX_TABLE = CREATE TABLE JMS_TRANSACTIONS ( TXID INTEGER )


      -->

      <!-- ==================================================================== -->
      <!-- System Destinations -->
      <!-- ==================================================================== -->

      <!-- Dead Letter Queue -->

      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
      <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager