3 Replies Latest reply on Nov 23, 2009 10:49 PM by Yong Hao Gao

    Exception when trying to get ConnectionFactory

    Mike Sacauskis Newbie

      I have this simple program to use JMS. When it runs:
      TopicConnectionFactory tcf = (TopicConnectionFactory) context.lookup("ConnectionFactory");

      I get an exception:
      Exception in thread "main" java.lang.NoClassDefFoundError: javassist/NotFoundException
      at org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate.(ClientConnectionFactoryDelegate.java)
      at sun.misc.Unsafe.ensureClassInitialized(Native Method)
      at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
      at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
      at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
      at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
      at java.lang.reflect.Field.getLong(Field.java:528)
      at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1614)
      at java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:52)
      at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:425)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.io.ObjectStreamClass.(ObjectStreamClass.java:413)
      at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
      at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:547)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
      at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
      at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at com.gdit.listener.JMSExample.testMessage(JMSExample.java:35)
      at com.gdit.listener.JMSExample.main(JMSExample.java:20)
      Caused by: java.lang.ClassNotFoundException: javassist.NotFoundException
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
      ... 30 more





      package com.gdit.listener;
      
      import java.util.Properties;
      
      import javax.jms.Message;
      import javax.jms.MessageListener;
      import javax.jms.TextMessage;
      import javax.jms.Topic;
      import javax.jms.TopicConnection;
      import javax.jms.TopicConnectionFactory;
      import javax.jms.TopicPublisher;
      import javax.jms.TopicSession;
      import javax.jms.TopicSubscriber;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      
      public class JMSExample implements MessageListener {
      
       public static void main(String argc[]) {
       new JMSExample().testMessage();
       }
      
       public void testMessage() {
       TopicConnection conn = null;
       TopicSession session = null;
       Topic topic = null;
       try {
       Properties props = new Properties();
       props.setProperty("java.naming.factory.initial",
       "org.jboss.naming.NamingContextFactory");
       props.setProperty("java.naming.factory.url.pkgs",
       "org.jboss.naming");
       props.setProperty("java.naming.provider.url", "jnp://localhost:1199");
       Context context = new InitialContext(props);
       TopicConnectionFactory tcf = (TopicConnectionFactory) context.lookup("ConnectionFactory");
       conn = tcf.createTopicConnection();
       topic = (Topic) context.lookup("topic/testTopic");
       session = conn.createTopicSession(false,
       TopicSession.AUTO_ACKNOWLEDGE);
       conn.start();
       TopicPublisher send = session.createPublisher(topic);
       TextMessage tm = session.createTextMessage("JavaBeat Test Message");
       send.publish(tm);
       send.close();
       TopicSubscriber topicSubscriber = session.createSubscriber(
       topic);
       topicSubscriber.setMessageListener(this);
       while (true) {
       Message message = topicSubscriber.receive(1);
       if (message != null) {
       if (message instanceof TextMessage) {
       TextMessage textMessage = (TextMessage) message;
       System.out.println(message);
       System.out.println(
       textMessage.getText());
       } else {
       break;
       }
       }
       }
      
       } catch (Exception e) {
       System.out.println(e.toString() + " Does the queue exist?");
       e.printStackTrace();
       }
       }
      
       public void onMessage(Message message) {
       try {
       TextMessage textMessage = (TextMessage) message;
       String text = textMessage.getText();
       System.out.println(text);
       } catch (Exception jmse) {
       jmse.printStackTrace();
       }
       }
      }
      

      I'm running jboss4.2.3GA and F:\jboss-messaging-1.4.5.GA on windows XP.


      Thanks for any help you can give.

      Mike