Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 612
  • Last Modified:

Solve my error in JMS

public class JMSQueue {
    // URL of the JMS server. DEFAULT_BROKER_URL will just mean
    // that JMS server is on localhost
    private static String url = "http://localhost:8161";

    // Name of the queue we will be sending messages to
    private static String subject = "foo.bar";

    public static void main(String[] args) throws JMSException {
        // Getting JMS connection from the server and starting it
        ConnectionFactory connectionFactory =
            new ActiveMQConnectionFactory(url);
        Connection connection = connectionFactory.createConnection();
        connection.start();

        // JMS messages are sent and received using a Session. We will
        // create here a non-transactional session object. If you want
        // to use transactions you should set the first parameter to 'true'
        Session session = connection.createSession(false,
            Session.AUTO_ACKNOWLEDGE);

        // Destination represents here our queue 'TESTQUEUE' on the
        // JMS server. You don't have to do anything special on the
        // server to create it, it will be created automatically.
        Destination destination = session.createQueue(subject);

        // MessageProducer is used for sending messages (as opposed
        // to MessageConsumer which is used for receiving them)
        MessageProducer producer = session.createProducer(destination);

        // We will send a small text message saying 'Hello' in Japanese
        TextMessage message = session.createTextMessage("Hello");

        // Here we are sending the message!
        producer.send(message);
        System.out.println("Sent message '" + message.getText() + "'");

        connection.close();
    }
}

it through the error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpMethod
      at org.apache.activemq.transport.http.HttpTransportFactory.createTransport(HttpTransportFactory.java:59)
      at org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.java:141)
      at org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.java:51)
      at org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:80)
      at org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:240)
      at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:255)
      at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:227)
      at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:175)
      at com.sm.JMSQueue.main(JMSQueue.java:20)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpMethod
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      ... 9 more

http://localhost:8161 it will open the admin page
0
Manikandan Thiagarajan
Asked:
Manikandan Thiagarajan
1 Solution
 
cmalakarCommented:
You need httpclient library in the class path of your application.

You can get it from...

http://hc.apache.org/httpclient-3.x/
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Change your URL to ... (assuming that you haven't change any of the defaults)

private static String url = "tcp://localhost:61616";

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now