You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Michael <mt...@optonline.net> on 2011/05/21 05:09:24 UTC

java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

I am trying to run a very simple ActiveMQ message producer client.  The
source code is provided below.

 

I am launching the app from Eclipse using the Run menu.  I have configured a
Run Configuration For the client app.  On the classpath tab of the Run
Configuration for the app I have included activemq-all-5.5.0.jar,
slf4j-simple-1.5.11 and httpclient-4.1.1.jar.

 

When I run the app I get the following stack trace provided below.  Can
anyone tell me what might be wrong?

 

Thank you.

 

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/httpclient/HttpMethod

      at
org.apache.activemq.transport.http.HttpTransportFactory.createTransport(Http
TransportFactory.java:75)

      at
org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.ja
va:141)

      at
org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.ja
va:51)

      at
org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java
:80)

      at
org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnec
tionFactory.java:243)

      at
org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(Activ
eMQConnectionFactory.java:258)

      at
org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(Activ
eMQConnectionFactory.java:230)

      at
org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConne
ctionFactory.java:178)

      at JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)

      at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)

Caused by: java.lang.ClassNotFoundException:
org.apache.commons.httpclient.HttpMethod

      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)

      ... 10 more

 

import java.util.Vector;

 

import javax.jms.Connection;

import javax.jms.Session;

import javax.jms.Destination;

import javax.jms.DeliveryMode;

import javax.jms.MessageProducer;

import javax.jms.TextMessage;

 

import org.apache.activemq.ActiveMQConnection;

import org.apache.activemq.ActiveMQConnectionFactory;

 

public class JMSActiveMQPublisherApp

{

    private String user         = ActiveMQConnection.DEFAULT_USER;

    private String password     = ActiveMQConnection.DEFAULT_PASSWORD;

    private String url          = "http://localhost:8161/";

    private String subject      = "Subject.One";

    private int    messageCount = 10;

    private long   sleepTime    = 10000;

 

    

    private Destination destination;

 

    public static void main(String[] args)

      {

      JMSActiveMQPublisherApp app = new JMSActiveMQPublisherApp( );

      app.Execute();

      }

    

    public void Execute( )

    {

        Connection connection = null;

        try

        {

            // Create the connection.

            ActiveMQConnectionFactory connectionFactory =

                  new ActiveMQConnectionFactory(user, password, url);

            connection = connectionFactory.createConnection();

            connection.start();

 

            // Create the session

            // The argument false indicates that this session is not
transacted

            Session session = 

                  connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

 

            // Note that this method is not for creating the physical topic.

            // The physical creation of topics is an administrative task and

            // is not to be initiated by the JMS API.

            //

            // So a publisher can not create new topics.  The topics must

            // be created manually.  The publisher can only send messages to

            // already existing topics.

            //

            // This appears to be a severely limited implementation of the

            // publish/subscribe model!!!

            destination = session.createTopic(subject);

 

            // Create the producer.

            MessageProducer producer = session.createProducer(destination);

            producer.setDeliveryMode(DeliveryMode.PERSISTENT);

 

            // Start sending messages

            SendLoop(session, producer);

 

 

        }

        catch (Exception e)

        {

            System.out.println("Exception: " + e.getMessage());

            e.printStackTrace();

        }

        finally 

        {

            try

            {

                connection.close();

            }

            catch (Throwable ignore)

            {

            }

        }

    }

    

    private void SendLoop(Session session, MessageProducer producer) throws
Exception

    {

 

        for (int i = 0; i < messageCount || messageCount == 0; i++) {

 

            TextMessage message = session.createTextMessage("This is message
" + messageCount + " for topic Subject.One!" );

 

            producer.send(message);

            

            System.out.println("Message " + messageCount + " sent to topic
Subject.One");

 

            Thread.sleep(sleepTime);

        }

    }

}

 


RE: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Michael <mt...@optonline.net>.
Been there, done that!

-----Original Message-----
From: Norman Maurer [mailto:norman.maurer@googlemail.com] 
Sent: Saturday, May 21, 2011 10:47 AM
To: users@activemq.apache.org
Cc: slewis@fusesource.com
Subject: Re: java.lang.NoClassDefFoundError:
org/apache/commons/httpclient/HttpMethod

just include the httpclient jar in your classpath

bye
norman


Am Samstag, 21. Mai 2011 schrieb Michael <mt...@optonline.net>:
> Where can I it?  Looked everywhere!
>
> -----Original Message-----
> From: Stan Lewis [mailto:slewis@fusesource.com]
> Sent: Saturday, May 21, 2011 8:25 AM
> To: users@activemq.apache.org
> Subject: Re: java.lang.NoClassDefFoundError: 
> org/apache/commons/httpclient/HttpMethod
>
> The HTTP transport classes are in the activemq-optional jar.
>
> On Fri, May 20, 2011 at 11:09 PM, Michael <mt...@optonline.net>
wrote:
>> I am trying to run a very simple ActiveMQ message producer client.
>> The source code is provided below.
>>
>>
>>
>> I am launching the app from Eclipse using the Run menu.  I have 
>> configured a Run Configuration For the client app.  On the classpath 
>> tab of the Run Configuration for the app I have included 
>> activemq-all-5.5.0.jar,
>> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
>>
>>
>>
>> When I run the app I get the following stack trace provided below.
>> Can anyone tell me what might be wrong?
>>
>>
>>
>> Thank you.
>>
>>
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/commons/httpclient/HttpMethod
>>
>>      at
>> org.apache.activemq.transport.http.HttpTransportFactory.createTranspo
>> r
>> t(Http
>> TransportFactory.java:75)
>>
>>      at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFac
>> t
>> ory.ja
>> va:141)
>>
>>      at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFac
>> t
>> ory.ja
>> va:51)
>>
>>      at
>> org.apache.activemq.transport.TransportFactory.connect(TransportFacto
>> r
>> y.java
>> :80)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveM
>> Q
>> Connec
>> tionFactory.java:243)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnectio
>> n
>> (Activ
>> eMQConnectionFactory.java:258)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnectio
>> n
>> (Activ
>> eMQConnectionFactory.java:230)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createConnection(Active
>> M
>> QConne
>> ctionFactory.java:178)
>>
>>      at
>> JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
>>
>>      at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
>>
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.commons.httpclient.HttpMethod
>>
>>      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)
>>
>>      ... 10 more
>>
>>
>>
>> import java.util.Vector;
>>
>>
>>
>> import javax.jms.Connection;
>>
>> import javax.jms.Session;
>>
>> import javax.jms.Destination;
>>
>> import javax.jms.DeliveryMode;
>>
>> import javax.jms.MessageProducer;
>>
>> import javax.jms.TextMessage;
>>
>>
>>
>> import org.apache.activemq.ActiveMQConnection;
>>
>> import org.apache.activemq.ActiveMQConnectionFactory;
>>
>>
>>
>> public class JMSActiveMQPublisherApp
>>
>> {
>>
>>    private String user         = ActiveMQConnection.DEFAULT_USER;
>>
>>    private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
>>
>


Re: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Norman Maurer <no...@googlemail.com>.
just include the httpclient jar in your classpath

bye
norman


Am Samstag, 21. Mai 2011 schrieb Michael <mt...@optonline.net>:
> Where can I it?  Looked everywhere!
>
> -----Original Message-----
> From: Stan Lewis [mailto:slewis@fusesource.com]
> Sent: Saturday, May 21, 2011 8:25 AM
> To: users@activemq.apache.org
> Subject: Re: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
>
> The HTTP transport classes are in the activemq-optional jar.
>
> On Fri, May 20, 2011 at 11:09 PM, Michael <mt...@optonline.net> wrote:
>> I am trying to run a very simple ActiveMQ message producer client.
>> The source code is provided below.
>>
>>
>>
>> I am launching the app from Eclipse using the Run menu.  I have
>> configured a Run Configuration For the client app.  On the classpath
>> tab of the Run Configuration for the app I have included
>> activemq-all-5.5.0.jar,
>> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
>>
>>
>>
>> When I run the app I get the following stack trace provided below.
>> Can anyone tell me what might be wrong?
>>
>>
>>
>> Thank you.
>>
>>
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/commons/httpclient/HttpMethod
>>
>>      at
>> org.apache.activemq.transport.http.HttpTransportFactory.createTranspor
>> t(Http
>> TransportFactory.java:75)
>>
>>      at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
>> ory.ja
>> va:141)
>>
>>      at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
>> ory.ja
>> va:51)
>>
>>      at
>> org.apache.activemq.transport.TransportFactory.connect(TransportFactor
>> y.java
>> :80)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQ
>> Connec
>> tionFactory.java:243)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
>> (Activ
>> eMQConnectionFactory.java:258)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
>> (Activ
>> eMQConnectionFactory.java:230)
>>
>>      at
>> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveM
>> QConne
>> ctionFactory.java:178)
>>
>>      at
>> JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
>>
>>      at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
>>
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.commons.httpclient.HttpMethod
>>
>>      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)
>>
>>      ... 10 more
>>
>>
>>
>> import java.util.Vector;
>>
>>
>>
>> import javax.jms.Connection;
>>
>> import javax.jms.Session;
>>
>> import javax.jms.Destination;
>>
>> import javax.jms.DeliveryMode;
>>
>> import javax.jms.MessageProducer;
>>
>> import javax.jms.TextMessage;
>>
>>
>>
>> import org.apache.activemq.ActiveMQConnection;
>>
>> import org.apache.activemq.ActiveMQConnectionFactory;
>>
>>
>>
>> public class JMSActiveMQPublisherApp
>>
>> {
>>
>>    private String user         = ActiveMQConnection.DEFAULT_USER;
>>
>>    private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
>>
>

RE: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Michael <mt...@optonline.net>.
Where can I it?  Looked everywhere!

-----Original Message-----
From: Stan Lewis [mailto:slewis@fusesource.com] 
Sent: Saturday, May 21, 2011 8:25 AM
To: users@activemq.apache.org
Subject: Re: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

The HTTP transport classes are in the activemq-optional jar.

On Fri, May 20, 2011 at 11:09 PM, Michael <mt...@optonline.net> wrote:
> I am trying to run a very simple ActiveMQ message producer client.  
> The source code is provided below.
>
>
>
> I am launching the app from Eclipse using the Run menu.  I have 
> configured a Run Configuration For the client app.  On the classpath 
> tab of the Run Configuration for the app I have included 
> activemq-all-5.5.0.jar,
> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
>
>
>
> When I run the app I get the following stack trace provided below.  
> Can anyone tell me what might be wrong?
>
>
>
> Thank you.
>
>
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/httpclient/HttpMethod
>
>      at
> org.apache.activemq.transport.http.HttpTransportFactory.createTranspor
> t(Http
> TransportFactory.java:75)
>
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
> ory.ja
> va:141)
>
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
> ory.ja
> va:51)
>
>      at
> org.apache.activemq.transport.TransportFactory.connect(TransportFactor
> y.java
> :80)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQ
> Connec
> tionFactory.java:243)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
> (Activ
> eMQConnectionFactory.java:258)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
> (Activ
> eMQConnectionFactory.java:230)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveM
> QConne
> ctionFactory.java:178)
>
>      at 
> JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
>
>      at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
>
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.httpclient.HttpMethod
>
>      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)
>
>      ... 10 more
>
>
>
> import java.util.Vector;
>
>
>
> import javax.jms.Connection;
>
> import javax.jms.Session;
>
> import javax.jms.Destination;
>
> import javax.jms.DeliveryMode;
>
> import javax.jms.MessageProducer;
>
> import javax.jms.TextMessage;
>
>
>
> import org.apache.activemq.ActiveMQConnection;
>
> import org.apache.activemq.ActiveMQConnectionFactory;
>
>
>
> public class JMSActiveMQPublisherApp
>
> {
>
>    private String user         = ActiveMQConnection.DEFAULT_USER;
>
>    private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
>
>    private String url          = "http://localhost:8161/";
>
>    private String subject      = "Subject.One";
>
>    private int    messageCount = 10;
>
>    private long   sleepTime    = 10000;
>
>
>
>
>
>    private Destination destination;
>
>
>
>    public static void main(String[] args)
>
>      {
>
>      JMSActiveMQPublisherApp app = new JMSActiveMQPublisherApp( );
>
>      app.Execute();
>
>      }
>
>
>
>    public void Execute( )
>
>    {
>
>        Connection connection = null;
>
>        try
>
>        {
>
>            // Create the connection.
>
>            ActiveMQConnectionFactory connectionFactory =
>
>                  new ActiveMQConnectionFactory(user, password, url);
>
>            connection = connectionFactory.createConnection();
>
>            connection.start();
>
>
>
>            // Create the session
>
>            // The argument false indicates that this session is not 
> transacted
>
>            Session session =
>
>                  connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
>
>
>
>            // Note that this method is not for creating the physical topic.
>
>            // The physical creation of topics is an administrative 
> task and
>
>            // is not to be initiated by the JMS API.
>
>            //
>
>            // So a publisher can not create new topics.  The topics 
> must
>
>            // be created manually.  The publisher can only send 
> messages to
>
>            // already existing topics.
>
>            //
>
>            // This appears to be a severely limited implementation of 
> the
>
>            // publish/subscribe model!!!
>
>            destination = session.createTopic(subject);
>
>
>
>            // Create the producer.
>
>            MessageProducer producer = 
> session.createProducer(destination);
>
>            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>
>
>
>            // Start sending messages
>
>            SendLoop(session, producer);
>
>
>
>
>
>        }
>
>        catch (Exception e)
>
>        {
>
>            System.out.println("Exception: " + e.getMessage());
>
>            e.printStackTrace();
>
>        }
>
>        finally
>
>        {
>
>            try
>
>            {
>
>                connection.close();
>
>            }
>
>            catch (Throwable ignore)
>
>            {
>
>            }
>
>        }
>
>    }
>
>
>
>    private void SendLoop(Session session, MessageProducer producer) 
> throws Exception
>
>    {
>
>
>
>        for (int i = 0; i < messageCount || messageCount == 0; i++) {
>
>
>
>            TextMessage message = session.createTextMessage("This is 
> message " + messageCount + " for topic Subject.One!" );
>
>
>
>            producer.send(message);
>
>
>
>            System.out.println("Message " + messageCount + " sent to 
> topic Subject.One");
>
>
>
>            Thread.sleep(sleepTime);
>
>        }
>
>    }
>
> }
>
>
>
>


Re: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Stan Lewis <sl...@fusesource.com>.
The HTTP transport classes are in the activemq-optional jar.

On Fri, May 20, 2011 at 11:09 PM, Michael <mt...@optonline.net> wrote:
> I am trying to run a very simple ActiveMQ message producer client.  The
> source code is provided below.
>
>
>
> I am launching the app from Eclipse using the Run menu.  I have configured a
> Run Configuration For the client app.  On the classpath tab of the Run
> Configuration for the app I have included activemq-all-5.5.0.jar,
> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
>
>
>
> When I run the app I get the following stack trace provided below.  Can
> anyone tell me what might be wrong?
>
>
>
> Thank you.
>
>
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/httpclient/HttpMethod
>
>      at
> org.apache.activemq.transport.http.HttpTransportFactory.createTransport(Http
> TransportFactory.java:75)
>
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.ja
> va:141)
>
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.ja
> va:51)
>
>      at
> org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java
> :80)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnec
> tionFactory.java:243)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(Activ
> eMQConnectionFactory.java:258)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(Activ
> eMQConnectionFactory.java:230)
>
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConne
> ctionFactory.java:178)
>
>      at JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
>
>      at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
>
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.httpclient.HttpMethod
>
>      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)
>
>      ... 10 more
>
>
>
> import java.util.Vector;
>
>
>
> import javax.jms.Connection;
>
> import javax.jms.Session;
>
> import javax.jms.Destination;
>
> import javax.jms.DeliveryMode;
>
> import javax.jms.MessageProducer;
>
> import javax.jms.TextMessage;
>
>
>
> import org.apache.activemq.ActiveMQConnection;
>
> import org.apache.activemq.ActiveMQConnectionFactory;
>
>
>
> public class JMSActiveMQPublisherApp
>
> {
>
>    private String user         = ActiveMQConnection.DEFAULT_USER;
>
>    private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
>
>    private String url          = "http://localhost:8161/";
>
>    private String subject      = "Subject.One";
>
>    private int    messageCount = 10;
>
>    private long   sleepTime    = 10000;
>
>
>
>
>
>    private Destination destination;
>
>
>
>    public static void main(String[] args)
>
>      {
>
>      JMSActiveMQPublisherApp app = new JMSActiveMQPublisherApp( );
>
>      app.Execute();
>
>      }
>
>
>
>    public void Execute( )
>
>    {
>
>        Connection connection = null;
>
>        try
>
>        {
>
>            // Create the connection.
>
>            ActiveMQConnectionFactory connectionFactory =
>
>                  new ActiveMQConnectionFactory(user, password, url);
>
>            connection = connectionFactory.createConnection();
>
>            connection.start();
>
>
>
>            // Create the session
>
>            // The argument false indicates that this session is not
> transacted
>
>            Session session =
>
>                  connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>
>
>
>            // Note that this method is not for creating the physical topic.
>
>            // The physical creation of topics is an administrative task and
>
>            // is not to be initiated by the JMS API.
>
>            //
>
>            // So a publisher can not create new topics.  The topics must
>
>            // be created manually.  The publisher can only send messages to
>
>            // already existing topics.
>
>            //
>
>            // This appears to be a severely limited implementation of the
>
>            // publish/subscribe model!!!
>
>            destination = session.createTopic(subject);
>
>
>
>            // Create the producer.
>
>            MessageProducer producer = session.createProducer(destination);
>
>            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>
>
>
>            // Start sending messages
>
>            SendLoop(session, producer);
>
>
>
>
>
>        }
>
>        catch (Exception e)
>
>        {
>
>            System.out.println("Exception: " + e.getMessage());
>
>            e.printStackTrace();
>
>        }
>
>        finally
>
>        {
>
>            try
>
>            {
>
>                connection.close();
>
>            }
>
>            catch (Throwable ignore)
>
>            {
>
>            }
>
>        }
>
>    }
>
>
>
>    private void SendLoop(Session session, MessageProducer producer) throws
> Exception
>
>    {
>
>
>
>        for (int i = 0; i < messageCount || messageCount == 0; i++) {
>
>
>
>            TextMessage message = session.createTextMessage("This is message
> " + messageCount + " for topic Subject.One!" );
>
>
>
>            producer.send(message);
>
>
>
>            System.out.println("Message " + messageCount + " sent to topic
> Subject.One");
>
>
>
>            Thread.sleep(sleepTime);
>
>        }
>
>    }
>
> }
>
>
>
>

RE: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Michael <mt...@optonline.net>.
Thanks Tim.  I thought I looked everywhere, except right under my nose!

-----Original Message-----
From: Timothy Bish [mailto:tabish121@gmail.com] 
Sent: Saturday, May 21, 2011 3:17 PM
To: users@activemq.apache.org
Subject: RE: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

The activemq-optional jar is in the directory named optional under the lib dir, so ${activemq-base}/lib/optional/activemq-optional-5.5.0.jar.
You should find everything you need in that folder.

Regards


On Sat, 2011-05-21 at 15:06 -0400, Michael wrote:
> You know someone else that answered my post mentioned 
> activemq-optional.  No JAR file with that name was included with my download of ActiveMQ 5.5.0.
> 
> Can you tell me where I can get it?  I've looked in a few places and 
> can't seem to find one anywhere.
> 
> I also have a question about your comment on the commons-httpclient.  
> As you can see from my original email I'm including 
> httpclient-4.1.1.jar.  I thought this would do the trick.  The reason 
> I thought this is because when I looked on the Apache commons site it 
> stated that the commons project was replaced by the components 
> project.  It appeared to me that this was the place to get the 
> httpclient JAR I needed.  One response seemed to indicate that if I 
> used the activemq-optional JAR I would not need commons-httpclient.  Do you know if that is the case?
> 
> Is there someplace where an exact list of JARs needed is clearly 
> spelled out?  The ActiveMQ web site page that contains the list of 
> Required and Optional JARs is not very clear!
> 
> Thank you.


--
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/

Connect at CamelOne May 24-26

The Open Source Integration Conference


RE: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Timothy Bish <ta...@gmail.com>.
The activemq-optional jar is in the directory named optional under the
lib dir, so ${activemq-base}/lib/optional/activemq-optional-5.5.0.jar.
You should find everything you need in that folder.

Regards


On Sat, 2011-05-21 at 15:06 -0400, Michael wrote:
> You know someone else that answered my post mentioned activemq-optional.  No
> JAR file with that name was included with my download of ActiveMQ 5.5.0.
> 
> Can you tell me where I can get it?  I've looked in a few places and can't
> seem to find one anywhere.
> 
> I also have a question about your comment on the commons-httpclient.  As you
> can see from my original email I'm including httpclient-4.1.1.jar.  I
> thought this would do the trick.  The reason I thought this is because when
> I looked on the Apache commons site it stated that the commons project was
> replaced by the components project.  It appeared to me that this was the
> place to get the httpclient JAR I needed.  One response seemed to indicate
> that if I used the activemq-optional JAR I would not need
> commons-httpclient.  Do you know if that is the case?
> 
> Is there someplace where an exact list of JARs needed is clearly spelled
> out?  The ActiveMQ web site page that contains the list of Required and
> Optional JARs is not very clear!
> 
> Thank you.


-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/

Connect at CamelOne May 24-26

The Open Source Integration Conference


RE: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Michael <mt...@optonline.net>.
You know someone else that answered my post mentioned activemq-optional.  No
JAR file with that name was included with my download of ActiveMQ 5.5.0.

Can you tell me where I can get it?  I've looked in a few places and can't
seem to find one anywhere.

I also have a question about your comment on the commons-httpclient.  As you
can see from my original email I'm including httpclient-4.1.1.jar.  I
thought this would do the trick.  The reason I thought this is because when
I looked on the Apache commons site it stated that the commons project was
replaced by the components project.  It appeared to me that this was the
place to get the httpclient JAR I needed.  One response seemed to indicate
that if I used the activemq-optional JAR I would not need
commons-httpclient.  Do you know if that is the case?

Is there someplace where an exact list of JARs needed is clearly spelled
out?  The ActiveMQ web site page that contains the list of Required and
Optional JARs is not very clear!

Thank you.

-----Original Message-----
From: Johan Edstrom [mailto:seijoed@gmail.com] 
Sent: Saturday, May 21, 2011 1:18 PM
To: users@activemq.apache.org
Subject: Re: java.lang.NoClassDefFoundError:
org/apache/commons/httpclient/HttpMethod

Make sure you also have apache-activemq-optional on the clients classpath as
well as a http transport defined on the broker, the broker will need the
same library for the http transport.

Cheers.

On May 21, 2011, at 11:11 AM, Michael wrote:

> Thanks Johan.  I see the URL error.  I'll fix it and give it another try!
> 
> -----Original Message-----
> From: Johan Edstrom [mailto:seijoed@gmail.com]
> Sent: Saturday, May 21, 2011 12:08 PM
> To: users@activemq.apache.org
> Subject: Re: java.lang.NoClassDefFoundError:
> org/apache/commons/httpclient/HttpMethod
> 
> Not sure what you have been reading really,
> 
> But you are trying to use a jms "client/producer" against the activemq 
> webapp, not a transport, you are also missing commons-httpclient on 
> the classpath.
> 
> /je
> 
> On May 20, 2011, at 9:09 PM, Michael wrote:
> 
>> I am trying to run a very simple ActiveMQ message producer client.  
>> The source code is provided below.
>> 
>> 
>> 
>> I am launching the app from Eclipse using the Run menu.  I have 
>> configured a Run Configuration For the client app.  On the classpath 
>> tab of the Run Configuration for the app I have included 
>> activemq-all-5.5.0.jar,
>> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
>> 
>> 
>> 
>> When I run the app I get the following stack trace provided below.  
>> Can anyone tell me what might be wrong?
>> 
>> 
>> 
>> Thank you.
>> 
>> 
>> 
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/commons/httpclient/HttpMethod
>> 
>>     at
>> org.apache.activemq.transport.http.HttpTransportFactory.createTranspo
>> r
>> t(Http
>> TransportFactory.java:75)
>> 
>>     at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFac
>> t
>> ory.ja
>> va:141)
>> 
>>     at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFac
>> t
>> ory.ja
>> va:51)
>> 
>>     at
>> org.apache.activemq.transport.TransportFactory.connect(TransportFacto
>> r
>> y.java
>> :80)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveM
>> Q
>> Connec
>> tionFactory.java:243)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnectio
>> n
>> (Activ
>> eMQConnectionFactory.java:258)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnectio
>> n
>> (Activ
>> eMQConnectionFactory.java:230)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createConnection(Active
>> M
>> QConne
>> ctionFactory.java:178)
>> 
>>     at
>> JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
>> 
>>     at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
>> 
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.commons.httpclient.HttpMethod
>> 
>>     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)
>> 
>>     ... 10 more
>> 
>> 
>> 
>> import java.util.Vector;
>> 
>> 
>> 
>> import javax.jms.Connection;
>> 
>> import javax.jms.Session;
>> 
>> import javax.jms.Destination;
>> 
>> import javax.jms.DeliveryMode;
>> 
>> import javax.jms.MessageProducer;
>> 
>> import javax.jms.TextMessage;
>> 
>> 
>> 
>> import org.apache.activemq.ActiveMQConnection;
>> 
>> import org.apache.activemq.ActiveMQConnectionFactory;
>> 
>> 
>> 
>> public class JMSActiveMQPublisherApp
>> 
>> {
>> 
>>   private String user         = ActiveMQConnection.DEFAULT_USER;
>> 
>>   private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
>> 
>>   private String url          = "http://localhost:8161/";
>> 
>>   private String subject      = "Subject.One";
>> 
>>   private int    messageCount = 10;
>> 
>>   private long   sleepTime    = 10000;
>> 
>> 
>> 
>> 
>> 
>>   private Destination destination;
>> 
>> 
>> 
>>   public static void main(String[] args)
>> 
>>     {
>> 
>>     JMSActiveMQPublisherApp app = new JMSActiveMQPublisherApp( );
>> 
>>     app.Execute();
>> 
>>     }
>> 
>> 
>> 
>>   public void Execute( )
>> 
>>   {
>> 
>>       Connection connection = null;
>> 
>>       try
>> 
>>       {
>> 
>>           // Create the connection.
>> 
>>           ActiveMQConnectionFactory connectionFactory =
>> 
>>                 new ActiveMQConnectionFactory(user, password, url);
>> 
>>           connection = connectionFactory.createConnection();
>> 
>>           connection.start();
>> 
>> 
>> 
>>           // Create the session
>> 
>>           // The argument false indicates that this session is not 
>> transacted
>> 
>>           Session session =
>> 
>>                 connection.createSession(false, 
>> Session.AUTO_ACKNOWLEDGE);
>> 
>> 
>> 
>>           // Note that this method is not for creating the physical
> topic.
>> 
>>           // The physical creation of topics is an administrative 
>> task and
>> 
>>           // is not to be initiated by the JMS API.
>> 
>>           //
>> 
>>           // So a publisher can not create new topics.  The topics 
>> must
>> 
>>           // be created manually.  The publisher can only send 
>> messages to
>> 
>>           // already existing topics.
>> 
>>           //
>> 
>>           // This appears to be a severely limited implementation of 
>> the
>> 
>>           // publish/subscribe model!!!
>> 
>>           destination = session.createTopic(subject);
>> 
>> 
>> 
>>           // Create the producer.
>> 
>>           MessageProducer producer = 
>> session.createProducer(destination);
>> 
>>           producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>> 
>> 
>> 
>>           // Start sending messages
>> 
>>           SendLoop(session, producer);
>> 
>> 
>> 
>> 
>> 
>>       }
>> 
>>       catch (Exception e)
>> 
>>       {
>> 
>>           System.out.println("Exception: " + e.getMessage());
>> 
>>           e.printStackTrace();
>> 
>>       }
>> 
>>       finally
>> 
>>       {
>> 
>>           try
>> 
>>           {
>> 
>>               connection.close();
>> 
>>           }
>> 
>>           catch (Throwable ignore)
>> 
>>           {
>> 
>>           }
>> 
>>       }
>> 
>>   }
>> 
>> 
>> 
>>   private void SendLoop(Session session, MessageProducer producer) 
>> throws Exception
>> 
>>   {
>> 
>> 
>> 
>>       for (int i = 0; i < messageCount || messageCount == 0; i++) {
>> 
>> 
>> 
>>           TextMessage message = session.createTextMessage("This is 
>> message " + messageCount + " for topic Subject.One!" );
>> 
>> 
>> 
>>           producer.send(message);
>> 
>> 
>> 
>>           System.out.println("Message " + messageCount + " sent to 
>> topic Subject.One");
>> 
>> 
>> 
>>           Thread.sleep(sleepTime);
>> 
>>       }
>> 
>>   }
>> 
>> }
>> 
>> 
>> 
> 
> 



Re: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Johan Edstrom <se...@gmail.com>.
Make sure you also have apache-activemq-optional on the clients classpath
as well as a http transport defined on the broker, the broker will need the same library
for the http transport.

Cheers.

On May 21, 2011, at 11:11 AM, Michael wrote:

> Thanks Johan.  I see the URL error.  I'll fix it and give it another try!
> 
> -----Original Message-----
> From: Johan Edstrom [mailto:seijoed@gmail.com] 
> Sent: Saturday, May 21, 2011 12:08 PM
> To: users@activemq.apache.org
> Subject: Re: java.lang.NoClassDefFoundError:
> org/apache/commons/httpclient/HttpMethod
> 
> Not sure what you have been reading really, 
> 
> But you are trying to use a jms "client/producer" against the activemq
> webapp, not a transport, you are also missing commons-httpclient on the
> classpath.
> 
> /je
> 
> On May 20, 2011, at 9:09 PM, Michael wrote:
> 
>> I am trying to run a very simple ActiveMQ message producer client.  
>> The source code is provided below.
>> 
>> 
>> 
>> I am launching the app from Eclipse using the Run menu.  I have 
>> configured a Run Configuration For the client app.  On the classpath 
>> tab of the Run Configuration for the app I have included 
>> activemq-all-5.5.0.jar,
>> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
>> 
>> 
>> 
>> When I run the app I get the following stack trace provided below.  
>> Can anyone tell me what might be wrong?
>> 
>> 
>> 
>> Thank you.
>> 
>> 
>> 
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/commons/httpclient/HttpMethod
>> 
>>     at
>> org.apache.activemq.transport.http.HttpTransportFactory.createTranspor
>> t(Http
>> TransportFactory.java:75)
>> 
>>     at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
>> ory.ja
>> va:141)
>> 
>>     at
>> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
>> ory.ja
>> va:51)
>> 
>>     at
>> org.apache.activemq.transport.TransportFactory.connect(TransportFactor
>> y.java
>> :80)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQ
>> Connec
>> tionFactory.java:243)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
>> (Activ
>> eMQConnectionFactory.java:258)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
>> (Activ
>> eMQConnectionFactory.java:230)
>> 
>>     at
>> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveM
>> QConne
>> ctionFactory.java:178)
>> 
>>     at 
>> JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
>> 
>>     at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
>> 
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.commons.httpclient.HttpMethod
>> 
>>     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)
>> 
>>     ... 10 more
>> 
>> 
>> 
>> import java.util.Vector;
>> 
>> 
>> 
>> import javax.jms.Connection;
>> 
>> import javax.jms.Session;
>> 
>> import javax.jms.Destination;
>> 
>> import javax.jms.DeliveryMode;
>> 
>> import javax.jms.MessageProducer;
>> 
>> import javax.jms.TextMessage;
>> 
>> 
>> 
>> import org.apache.activemq.ActiveMQConnection;
>> 
>> import org.apache.activemq.ActiveMQConnectionFactory;
>> 
>> 
>> 
>> public class JMSActiveMQPublisherApp
>> 
>> {
>> 
>>   private String user         = ActiveMQConnection.DEFAULT_USER;
>> 
>>   private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
>> 
>>   private String url          = "http://localhost:8161/";
>> 
>>   private String subject      = "Subject.One";
>> 
>>   private int    messageCount = 10;
>> 
>>   private long   sleepTime    = 10000;
>> 
>> 
>> 
>> 
>> 
>>   private Destination destination;
>> 
>> 
>> 
>>   public static void main(String[] args)
>> 
>>     {
>> 
>>     JMSActiveMQPublisherApp app = new JMSActiveMQPublisherApp( );
>> 
>>     app.Execute();
>> 
>>     }
>> 
>> 
>> 
>>   public void Execute( )
>> 
>>   {
>> 
>>       Connection connection = null;
>> 
>>       try
>> 
>>       {
>> 
>>           // Create the connection.
>> 
>>           ActiveMQConnectionFactory connectionFactory =
>> 
>>                 new ActiveMQConnectionFactory(user, password, url);
>> 
>>           connection = connectionFactory.createConnection();
>> 
>>           connection.start();
>> 
>> 
>> 
>>           // Create the session
>> 
>>           // The argument false indicates that this session is not 
>> transacted
>> 
>>           Session session =
>> 
>>                 connection.createSession(false, 
>> Session.AUTO_ACKNOWLEDGE);
>> 
>> 
>> 
>>           // Note that this method is not for creating the physical
> topic.
>> 
>>           // The physical creation of topics is an administrative 
>> task and
>> 
>>           // is not to be initiated by the JMS API.
>> 
>>           //
>> 
>>           // So a publisher can not create new topics.  The topics 
>> must
>> 
>>           // be created manually.  The publisher can only send 
>> messages to
>> 
>>           // already existing topics.
>> 
>>           //
>> 
>>           // This appears to be a severely limited implementation of 
>> the
>> 
>>           // publish/subscribe model!!!
>> 
>>           destination = session.createTopic(subject);
>> 
>> 
>> 
>>           // Create the producer.
>> 
>>           MessageProducer producer = 
>> session.createProducer(destination);
>> 
>>           producer.setDeliveryMode(DeliveryMode.PERSISTENT);
>> 
>> 
>> 
>>           // Start sending messages
>> 
>>           SendLoop(session, producer);
>> 
>> 
>> 
>> 
>> 
>>       }
>> 
>>       catch (Exception e)
>> 
>>       {
>> 
>>           System.out.println("Exception: " + e.getMessage());
>> 
>>           e.printStackTrace();
>> 
>>       }
>> 
>>       finally
>> 
>>       {
>> 
>>           try
>> 
>>           {
>> 
>>               connection.close();
>> 
>>           }
>> 
>>           catch (Throwable ignore)
>> 
>>           {
>> 
>>           }
>> 
>>       }
>> 
>>   }
>> 
>> 
>> 
>>   private void SendLoop(Session session, MessageProducer producer) 
>> throws Exception
>> 
>>   {
>> 
>> 
>> 
>>       for (int i = 0; i < messageCount || messageCount == 0; i++) {
>> 
>> 
>> 
>>           TextMessage message = session.createTextMessage("This is 
>> message " + messageCount + " for topic Subject.One!" );
>> 
>> 
>> 
>>           producer.send(message);
>> 
>> 
>> 
>>           System.out.println("Message " + messageCount + " sent to 
>> topic Subject.One");
>> 
>> 
>> 
>>           Thread.sleep(sleepTime);
>> 
>>       }
>> 
>>   }
>> 
>> }
>> 
>> 
>> 
> 
> 


RE: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Michael <mt...@optonline.net>.
Thanks Johan.  I see the URL error.  I'll fix it and give it another try!

-----Original Message-----
From: Johan Edstrom [mailto:seijoed@gmail.com] 
Sent: Saturday, May 21, 2011 12:08 PM
To: users@activemq.apache.org
Subject: Re: java.lang.NoClassDefFoundError:
org/apache/commons/httpclient/HttpMethod

Not sure what you have been reading really, 

But you are trying to use a jms "client/producer" against the activemq
webapp, not a transport, you are also missing commons-httpclient on the
classpath.

/je

On May 20, 2011, at 9:09 PM, Michael wrote:

> I am trying to run a very simple ActiveMQ message producer client.  
> The source code is provided below.
> 
> 
> 
> I am launching the app from Eclipse using the Run menu.  I have 
> configured a Run Configuration For the client app.  On the classpath 
> tab of the Run Configuration for the app I have included 
> activemq-all-5.5.0.jar,
> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
> 
> 
> 
> When I run the app I get the following stack trace provided below.  
> Can anyone tell me what might be wrong?
> 
> 
> 
> Thank you.
> 
> 
> 
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/httpclient/HttpMethod
> 
>      at
> org.apache.activemq.transport.http.HttpTransportFactory.createTranspor
> t(Http
> TransportFactory.java:75)
> 
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
> ory.ja
> va:141)
> 
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFact
> ory.ja
> va:51)
> 
>      at
> org.apache.activemq.transport.TransportFactory.connect(TransportFactor
> y.java
> :80)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQ
> Connec
> tionFactory.java:243)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
> (Activ
> eMQConnectionFactory.java:258)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection
> (Activ
> eMQConnectionFactory.java:230)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveM
> QConne
> ctionFactory.java:178)
> 
>      at 
> JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
> 
>      at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
> 
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.httpclient.HttpMethod
> 
>      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)
> 
>      ... 10 more
> 
> 
> 
> import java.util.Vector;
> 
> 
> 
> import javax.jms.Connection;
> 
> import javax.jms.Session;
> 
> import javax.jms.Destination;
> 
> import javax.jms.DeliveryMode;
> 
> import javax.jms.MessageProducer;
> 
> import javax.jms.TextMessage;
> 
> 
> 
> import org.apache.activemq.ActiveMQConnection;
> 
> import org.apache.activemq.ActiveMQConnectionFactory;
> 
> 
> 
> public class JMSActiveMQPublisherApp
> 
> {
> 
>    private String user         = ActiveMQConnection.DEFAULT_USER;
> 
>    private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
> 
>    private String url          = "http://localhost:8161/";
> 
>    private String subject      = "Subject.One";
> 
>    private int    messageCount = 10;
> 
>    private long   sleepTime    = 10000;
> 
> 
> 
> 
> 
>    private Destination destination;
> 
> 
> 
>    public static void main(String[] args)
> 
>      {
> 
>      JMSActiveMQPublisherApp app = new JMSActiveMQPublisherApp( );
> 
>      app.Execute();
> 
>      }
> 
> 
> 
>    public void Execute( )
> 
>    {
> 
>        Connection connection = null;
> 
>        try
> 
>        {
> 
>            // Create the connection.
> 
>            ActiveMQConnectionFactory connectionFactory =
> 
>                  new ActiveMQConnectionFactory(user, password, url);
> 
>            connection = connectionFactory.createConnection();
> 
>            connection.start();
> 
> 
> 
>            // Create the session
> 
>            // The argument false indicates that this session is not 
> transacted
> 
>            Session session =
> 
>                  connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
> 
> 
> 
>            // Note that this method is not for creating the physical
topic.
> 
>            // The physical creation of topics is an administrative 
> task and
> 
>            // is not to be initiated by the JMS API.
> 
>            //
> 
>            // So a publisher can not create new topics.  The topics 
> must
> 
>            // be created manually.  The publisher can only send 
> messages to
> 
>            // already existing topics.
> 
>            //
> 
>            // This appears to be a severely limited implementation of 
> the
> 
>            // publish/subscribe model!!!
> 
>            destination = session.createTopic(subject);
> 
> 
> 
>            // Create the producer.
> 
>            MessageProducer producer = 
> session.createProducer(destination);
> 
>            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
> 
> 
> 
>            // Start sending messages
> 
>            SendLoop(session, producer);
> 
> 
> 
> 
> 
>        }
> 
>        catch (Exception e)
> 
>        {
> 
>            System.out.println("Exception: " + e.getMessage());
> 
>            e.printStackTrace();
> 
>        }
> 
>        finally
> 
>        {
> 
>            try
> 
>            {
> 
>                connection.close();
> 
>            }
> 
>            catch (Throwable ignore)
> 
>            {
> 
>            }
> 
>        }
> 
>    }
> 
> 
> 
>    private void SendLoop(Session session, MessageProducer producer) 
> throws Exception
> 
>    {
> 
> 
> 
>        for (int i = 0; i < messageCount || messageCount == 0; i++) {
> 
> 
> 
>            TextMessage message = session.createTextMessage("This is 
> message " + messageCount + " for topic Subject.One!" );
> 
> 
> 
>            producer.send(message);
> 
> 
> 
>            System.out.println("Message " + messageCount + " sent to 
> topic Subject.One");
> 
> 
> 
>            Thread.sleep(sleepTime);
> 
>        }
> 
>    }
> 
> }
> 
> 
> 



Re: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod

Posted by Johan Edstrom <se...@gmail.com>.
Not sure what you have been reading really, 

But you are trying to use a jms "client/producer" against the activemq webapp,
not a transport, you are also missing commons-httpclient on the classpath.

/je

On May 20, 2011, at 9:09 PM, Michael wrote:

> I am trying to run a very simple ActiveMQ message producer client.  The
> source code is provided below.
> 
> 
> 
> I am launching the app from Eclipse using the Run menu.  I have configured a
> Run Configuration For the client app.  On the classpath tab of the Run
> Configuration for the app I have included activemq-all-5.5.0.jar,
> slf4j-simple-1.5.11 and httpclient-4.1.1.jar.
> 
> 
> 
> When I run the app I get the following stack trace provided below.  Can
> anyone tell me what might be wrong?
> 
> 
> 
> Thank you.
> 
> 
> 
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/httpclient/HttpMethod
> 
>      at
> org.apache.activemq.transport.http.HttpTransportFactory.createTransport(Http
> TransportFactory.java:75)
> 
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.ja
> va:141)
> 
>      at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.ja
> va:51)
> 
>      at
> org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java
> :80)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnec
> tionFactory.java:243)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(Activ
> eMQConnectionFactory.java:258)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(Activ
> eMQConnectionFactory.java:230)
> 
>      at
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConne
> ctionFactory.java:178)
> 
>      at JMSActiveMQPublisherApp.Execute(JMSActiveMQPublisherApp.java:39)
> 
>      at JMSActiveMQPublisherApp.main(JMSActiveMQPublisherApp.java:28)
> 
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.httpclient.HttpMethod
> 
>      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)
> 
>      ... 10 more
> 
> 
> 
> import java.util.Vector;
> 
> 
> 
> import javax.jms.Connection;
> 
> import javax.jms.Session;
> 
> import javax.jms.Destination;
> 
> import javax.jms.DeliveryMode;
> 
> import javax.jms.MessageProducer;
> 
> import javax.jms.TextMessage;
> 
> 
> 
> import org.apache.activemq.ActiveMQConnection;
> 
> import org.apache.activemq.ActiveMQConnectionFactory;
> 
> 
> 
> public class JMSActiveMQPublisherApp
> 
> {
> 
>    private String user         = ActiveMQConnection.DEFAULT_USER;
> 
>    private String password     = ActiveMQConnection.DEFAULT_PASSWORD;
> 
>    private String url          = "http://localhost:8161/";
> 
>    private String subject      = "Subject.One";
> 
>    private int    messageCount = 10;
> 
>    private long   sleepTime    = 10000;
> 
> 
> 
> 
> 
>    private Destination destination;
> 
> 
> 
>    public static void main(String[] args)
> 
>      {
> 
>      JMSActiveMQPublisherApp app = new JMSActiveMQPublisherApp( );
> 
>      app.Execute();
> 
>      }
> 
> 
> 
>    public void Execute( )
> 
>    {
> 
>        Connection connection = null;
> 
>        try
> 
>        {
> 
>            // Create the connection.
> 
>            ActiveMQConnectionFactory connectionFactory =
> 
>                  new ActiveMQConnectionFactory(user, password, url);
> 
>            connection = connectionFactory.createConnection();
> 
>            connection.start();
> 
> 
> 
>            // Create the session
> 
>            // The argument false indicates that this session is not
> transacted
> 
>            Session session = 
> 
>                  connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
> 
> 
> 
>            // Note that this method is not for creating the physical topic.
> 
>            // The physical creation of topics is an administrative task and
> 
>            // is not to be initiated by the JMS API.
> 
>            //
> 
>            // So a publisher can not create new topics.  The topics must
> 
>            // be created manually.  The publisher can only send messages to
> 
>            // already existing topics.
> 
>            //
> 
>            // This appears to be a severely limited implementation of the
> 
>            // publish/subscribe model!!!
> 
>            destination = session.createTopic(subject);
> 
> 
> 
>            // Create the producer.
> 
>            MessageProducer producer = session.createProducer(destination);
> 
>            producer.setDeliveryMode(DeliveryMode.PERSISTENT);
> 
> 
> 
>            // Start sending messages
> 
>            SendLoop(session, producer);
> 
> 
> 
> 
> 
>        }
> 
>        catch (Exception e)
> 
>        {
> 
>            System.out.println("Exception: " + e.getMessage());
> 
>            e.printStackTrace();
> 
>        }
> 
>        finally 
> 
>        {
> 
>            try
> 
>            {
> 
>                connection.close();
> 
>            }
> 
>            catch (Throwable ignore)
> 
>            {
> 
>            }
> 
>        }
> 
>    }
> 
> 
> 
>    private void SendLoop(Session session, MessageProducer producer) throws
> Exception
> 
>    {
> 
> 
> 
>        for (int i = 0; i < messageCount || messageCount == 0; i++) {
> 
> 
> 
>            TextMessage message = session.createTextMessage("This is message
> " + messageCount + " for topic Subject.One!" );
> 
> 
> 
>            producer.send(message);
> 
> 
> 
>            System.out.println("Message " + messageCount + " sent to topic
> Subject.One");
> 
> 
> 
>            Thread.sleep(sleepTime);
> 
>        }
> 
>    }
> 
> }
> 
> 
>