Rabbitmq Debian 8 Exception: NoClassDefFoundError: com/rabbitmq/client/connectionfactory

1,723 views
Skip to first unread message

Mohamed Tarek

unread,
Oct 16, 2017, 12:20:07 PM10/16/17
to rabbitmq-users
Hello,

I am using Debian 8 box with my code as Java service in which, I am calling Rabbitmq remote Windows 10 PC from this (Rabbitmq client) service to post messages from my box.
RabbitMQ server is installed successfully on this PC and performing well. The issue is with the Debian client code.

JDK ver: 1.6  

I am getting the below exception for the SENDER part:

Exception in thread "Thread-0" java.lang.NoClassDefFoundError: com/rabbitmq/client/ConnectionFactory

        at com.protonss.resortApp.Rabbit_Message_Queue.SendMessage(Rabbit_Message_Queue.java:41)

        at com.protonss.resortApp.CardMonitorMainThread.handleCard(CardMonitorMainThread.java:357)

        at com.protonss.resortApp.CardMonitorMainThread.run(CardMonitorMainThread.java:171)

        at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.ClassNotFoundException: com.rabbitmq.client.ConnectionFactory

        at java.net.URLClassLoader$1.run(URLClassLoader.java:359)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:348)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:347)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)


Using the below code:


public boolean SendMessage (String IP , byte[] ImageBinary )

        {

            boolean Result = false;

            try

           {


        Utilities.log("ConnectionFactory factory = new ConnectionFactory();  ImageBinary :"+ImageBinary, "IP"+IP );

                ConnectionFactory factory = new ConnectionFactory();

               

                factory.setHost(IP);

                Utilities.log(" factory.setHost(IP);",IP);

                

                Connection connection = factory.newConnection();

                Utilities.log(" Connection connection = factory.newConnection();",IP);

                Channel channel = connection.createChannel();

                Utilities.log(" Channel channel = connection.createChannel();","");

                channel.queueDeclare(QUEUE_NAME, false, false, false, null);

                Utilities.log("  channel.queueDeclare(QUEUE_NAME, false, false, false, null);" , QUEUE_NAME);


             

                channel.basicPublish("", QUEUE_NAME, null, ImageBinary);

                Utilities.log(" channel.basicPublish(, QUEUE_NAME, null, ImageBinary); " , QUEUE_NAME);

                System.out.println(" [x] Sent '" + ImageBinary.toString() + "'");

                Utilities.log(" ****************************************SendMessage sent **********************************************" , "");

                channel.close();

                Utilities.log(" SendMessage: channel Close  " , "");

                connection.close();

                Utilities.log(" SendMessage:connection Close" , "");

                Result=true;

                Utilities.log(" SendMessage: result true " , "");

               

            }

            catch(Exception Ex )

            {

                Utilities.logError(Ex.getMessage());

            }

        return Result ;

        }   


The jar files are included in the compilation time and accordingly, the run-time.


I too included the command "export CP=.:amqp-client-4.0.2.jar:slf4j-api-1.7.21.jar:slf4j-simple-1.7.22.jar" in the startup script prior to calling the Java service but still the same issue.


Any swift support is highly appreciated. 

Michael Klishin

unread,
Oct 16, 2017, 3:17:17 PM10/16/17
to rabbitm...@googlegroups.com
RabbitMQ Java client must be on the JVM's classpath.

You have provided no information about how the client was obtained, how your application
is built and so on. With modern build tools such as Maven and Gradle all you need to do is to add
a dependency [1].

Running ./recompile.sh in the runnable Java tutorials directory and then using
the README instructions [2] works for me.


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Mohamed Tarek

unread,
Oct 17, 2017, 8:25:22 AM10/17/17
to rabbitmq-users
Thanks Michael, placing the 3 JARs in Java folder & setting the ClassPath with these JARs have fixed the issue.

Best regards
---------------------
Reply all
Reply to author
Forward
0 new messages