ConnectionFactory Class not found in Java

159 views
Skip to first unread message

George

unread,
Jul 14, 2012, 11:03:46 PM7/14/12
to rabbitmq...@googlegroups.com
I am attempting to run a Java class I developed called Send to publish messages. It breaks on creating a connection. This is on a Windows server with the RabbitMQ service running successfully - I can use it fine with Node.

Here is my Java compile statement:
C:\java>javac -classpath commons-io-1.2.jar;commons-cli-1.1.jar;junit.jar;rabbitmq-client.jar;rabbitmq-client-tests.jar Send.java

Here is the code
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.*;

public class Send {

  public static void main(String[] argv) throws Exception {

      ConnectionFactory factory = new ConnectionFactory();

  }
}

Here are the results
C:\java>java Send
Exception in thread "main" java.lang.NoClassDefFoundError: com/rabbitmq/client/ConnectionFactory
        at Send.main(Send.java:10)
Caused by: java.lang.ClassNotFoundException: com.rabbitmq.client.ConnectionFactory
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)

Has anyone encountered and resolved this issue? Two thoughts I have are ConnectionFactory is dependent on classes not in my compile command and that ConnectionFactory has no parameter-less definitions.

Thanks for any help,

George


George

unread,
Jul 15, 2012, 7:32:09 AM7/15/12
to rabbitmq...@googlegroups.com
I resolved the issue. It needed the -classpath option on the java run command also.

Michael Oki

unread,
Jul 24, 2013, 6:56:57 AM7/24/13
to rabbitmq...@googlegroups.com
Hello peeps, where can I get all the files that were used in the Rabbit MQ example?
Reply all
Reply to author
Forward
0 new messages