ActiveMQ http connection error

2k views Asked by At

I am trying to connect my java client application to ActiveMQ over http, but keep getting an error: (complete error at the bottom)

javax.jms.JMSException: Could not post command: ProducerInfo 
No such field org.apache.activemq.command.ProducerInfo.sentCount

Also, there is connection to ActiveMQ, because the server also produces an error: (complete error at the bottom)

com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field 
org.apache.activemq.command.ProducerInfo.sentCount

Is there a library or jar problem?

This connections works why I connect with: tcp://localhost:61616

activemq.xml

<broker>
  ...
  <transportConnectors>
    <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="http" uri="http://0.0.0.0:8081"/>
  </transportConnectors>
  ...
</broker>

jndi.properties in my Java Client program:

java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
#java.naming.provider.url = tcp://localhost:61616
java.naming.provider.url = http://localhost:8081
connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry
queue.testQueue = testQueue

Java Client

package be.jmshub.jmsremotejndiproducer;

import javax.jms.JMSException;
import javax.jms.Connection;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Producer {

    public static void main(String[] args) throws JMSException {

        System.out.println("JMS REMOTE PRODUCER: start");

        try {
            // create a new intial context, which loads from jndi.properties file
            Context ctx = new InitialContext();
            QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("connectionFactory");
            Connection connection = factory.createConnection();
            Queue queue = (javax.jms.Queue) ctx.lookup("testQueue");
            Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);

            MessageProducer producer = session.createProducer(queue);

            System.out.println("JMS REMOTE PRODUCER: connected");

            int count = 0;

            for (int i = 0; i < 5; i++) {
                String messageText = "This is message " + (i + 1);
                Message message = session.createTextMessage(messageText);
                System.out.println("JMS REMOTE PRODUCER: sending - " + messageText);
                producer.send(message);
                count += 1;
            }
            System.out.println("JMS REMOTE PRODUCER: total messages sent: " + count);

            // Clean up
            session.close();
            connection.close();
        } catch (Exception ex) {
            System.out.println("JMS REMOTE PRODUCER: EXCEPTION:" + ex.toString());
        }
        System.out.println("JMS REMOTE PRODUCER: finished");
    }
}

This works with tcp://localhost:61616 but not with http://localhost:8080

Can any person help me get this thing up and running?

Client Error:

javax.jms.JMSException: Could not post command: ProducerInfo 
{commandId = 4, responseRequired = true, producerId = ID:pc-prd0170-57061-1434012164882-2:1:1:1, destination = queue://testQueue, brokerPath = null, dispatchAsync = false, windowSize = 0, sentCount = 0}
due to: java.io.IOException: Failed to post command: ProducerInfo
{commandId = 4, responseRequired = true, producerId = ID:pc-prd0170-57061-1434012164882-2:1:1:1, destination = queue://
testQueue, brokerPath = null, dispatchAsync = false, windowSize = 0, sentCount = 0}
as response was: HTTP/1.1 500 No such field org.apache.activemq.command.ProducerInfo.sentCount
---- Debugging information ---- 
field               : sentCount
class               : org.apache.activemq.command.ProducerInfo
required-type       : org.apache.activemq.command.ProducerInfo
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                :/org.apache.activemq.command.ProducerInfo/sentCount
line number         : 15
version             : null
------------------------------- 
[Cache-Control: must-revalidate,no-cache,no-store, Content-Type: text/html;charset=ISO-8859-1, Content-Length: 2251, Server: Jetty(7.6.7.v20120910)] org.apache.http.conn.BasicManagedEntity@1c222ae

SERVER ACTIVE MQ:

WARN | /
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field org.apache.activemq.command.ProducerInfo.sentCount
---- Debugging information ----
field               : sentCount
class               : org.apache.activemq.command.ProducerInfo
required-type       : org.apache.activemq.command.ProducerInfo
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
path                : /org.apache.activemq.command.ProducerInfo/sentCount
line number         : 15
version             : null
-------------------------------
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:453)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:294)
        at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
        at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
        at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
        at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1058)
        at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1042)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:913)
        at org.apache.activemq.transport.xstream.XStreamWireFormat.unmarshalText(XStreamWireFormat.java:57)
        at org.apache.activemq.transport.http.HttpTunnelServlet.doPost(HttpTunnelServlet.java:127)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:447)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
        at org.eclipse.jetty.server.handler.GzipHandler.handle(GzipHandler.java:275)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1040)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:374)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:972)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
        at org.eclipse.jetty.server.Server.handle(Server.java:363)
        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:483)
        at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:931)
        at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:992)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
        at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
        at java.lang.Thread.run(Thread.java:745)
1

There are 1 answers

1
SubOptimal On BEST ANSWER

I guess you are mixing different ActiveMQ version/packaging and one of them is 5.9.0 (or before). The field sentCount exist since version 5.9.1.

  • Version 5.9.0 was released on 14.Oct.2013
  • the field sentCount was added on 03.Dec.2013