Hi Marcus, It looks like you need to add the JMS jar to your classpath; see http://java.sun.com/products/jms/docs.html.
Dave. -----Original Message----- From: Marcus Schröder [mailto:[email protected]] Sent: Monday, May 11, 2009 5:04 AM To: [email protected] Subject: Using the Java client Hi, I'm trying to set up a QPID system here and am running the M4-C++ Broker, which I can access with the C++ and Ruby clients. The Java client, however, I cannot get working. When trying to compile the code examples, a bunch of errors occur: m...@marcus-desktop:~/Desktop/qpid-0.5/java/client/example/she/qpid/example/simple/reqresp$ javac -cp /home/mss/qpid-client-0.5/lib/qpid-all.jar Client.java ---------- 1. ERROR in Client.java (at line 24) import javax.jms.Connection; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 2. ERROR in Client.java (at line 25) import javax.jms.ConnectionFactory; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 3. ERROR in Client.java (at line 26) import javax.jms.Destination; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 4. ERROR in Client.java (at line 27) import javax.jms.JMSException; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 5. ERROR in Client.java (at line 28) import javax.jms.Message; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 6. ERROR in Client.java (at line 29) import javax.jms.MessageConsumer; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 7. ERROR in Client.java (at line 30) import javax.jms.MessageListener; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 8. ERROR in Client.java (at line 31) import javax.jms.MessageProducer; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 9. ERROR in Client.java (at line 32) import javax.jms.Queue; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 10. ERROR in Client.java (at line 33) import javax.jms.Session; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 11. ERROR in Client.java (at line 34) import javax.jms.TextMessage; ^^^^^^^^^ The import javax.jms cannot be resolved ---------- 12. ERROR in Client.java (at line 41) public class Client implements MessageListener ^^^^^^^^^^^^^^^ MessageListener cannot be resolved to a type ---------- 13. ERROR in Client.java (at line 62) Connection connection; ^^^^^^^^^^ Connection cannot be resolved to a type ---------- 14. ERROR in Client.java (at line 63) Session session; ^^^^^^^ Session cannot be resolved to a type ---------- 15. ERROR in Client.java (at line 64) Destination responseQueue; ^^^^^^^^^^^ Destination cannot be resolved to a type ---------- 16. ERROR in Client.java (at line 67) MessageProducer _producer; ^^^^^^^^^^^^^^^ MessageProducer cannot be resolved to a type ---------- 17. ERROR in Client.java (at line 70) connection = ((ConnectionFactory) lookupJNDI(CONNECTION_JNDI_NAME)).createConnection(); ^^^^^^^^^^^^^^^^^ ConnectionFactory cannot be resolved to a type ---------- 18. ERROR in Client.java (at line 72) session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); ^^^^^^^ Session cannot be resolved ---------- 19. ERROR in Client.java (at line 74) Destination requestQueue = (Queue) lookupJNDI(QUEUE_JNDI_NAME); ^^^^^^^^^^^ Destination cannot be resolved to a type ---------- 20. ERROR in Client.java (at line 74) Destination requestQueue = (Queue) lookupJNDI(QUEUE_JNDI_NAME); ^^^^^ Queue cannot be resolved to a type ---------- 21. ERROR in Client.java (at line 85) MessageConsumer responseConsumer = session.createConsumer(responseQueue); ^^^^^^^^^^^^^^^ MessageConsumer cannot be resolved to a type ---------- 22. ERROR in Client.java (at line 93) catch (JMSException e) ^^^^^^^^^^^^ JMSException cannot be resolved to a type ---------- 23. ERROR in Client.java (at line 100) TextMessage txtMessage; ^^^^^^^^^^^ TextMessage cannot be resolved to a type ---------- 24. ERROR in Client.java (at line 116) catch (JMSException e) ^^^^^^^^^^^^ JMSException cannot be resolved to a type ---------- 25. ERROR in Client.java (at line 127) catch (JMSException e) ^^^^^^^^^^^^ JMSException cannot be resolved to a type ---------- 26. ERROR in Client.java (at line 136) catch (JMSException e) ^^^^^^^^^^^^ JMSException cannot be resolved to a type ---------- 27. ERROR in Client.java (at line 156) catch (JMSException e) ^^^^^^^^^^^^ JMSException cannot be resolved to a type ---------- 28. ERROR in Client.java (at line 158) System.err.println("A problem occured while shutting down the connection : " + e); ^ e cannot be resolved ---------- 29. ERROR in Client.java (at line 169) public void onMessage(Message message) ^^^^^^^ Message cannot be resolved to a type ---------- 30. ERROR in Client.java (at line 174) if (message instanceof TextMessage) ^^^^^^^^^^^ TextMessage cannot be resolved to a type ---------- 31. ERROR in Client.java (at line 176) TextMessage textMessage = (TextMessage) message; ^^^^^^^^^^^ TextMessage cannot be resolved to a type ---------- 32. ERROR in Client.java (at line 176) TextMessage textMessage = (TextMessage) message; ^^^^^^^^^^^ TextMessage cannot be resolved to a type ---------- 33. ERROR in Client.java (at line 188) catch (JMSException e) ^^^^^^^^^^^^ JMSException cannot be resolved to a type ---------- 33 problems (33 errors) ------- When I add the javaee.jar from a current GlassFish installation to the classpath, these get reduced to: )m...@marcus-desktop:~/Desktop/qpid-0.5/java/client/examplehe/qpid/example/simple/reqresp$ javac -cp /opt/SDK/lib/javaee.jar:/home/mss/qpid-client-0.5/lib/qpid-all.jar Client.java ---------- 1. WARNING in Client.java (at line 233) Context ctx = null; ^^^ The local variable ctx is never read ---------- 1 problem (1 warning) ---------- Running the result fails, however: )m...@marcus-desktop:~/Desktop/qpid-0.5/java/client/example/she/qpid/example/simple/reqresp$ java Client Exception in thread "main" java.lang.NoClassDefFoundError: Client (wrong name: org/apache/qpid/example/simple/reqresp/Client) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) ------------- Any suggestions how to resolve this? My setup is running on Ubuntu 8.04 (in a VM). I use the Sun Java SDK 1.6.0_07 and tried the 0.5-RC2 Java client for this. Kind regards, Marcus --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[email protected] --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[email protected]
