Activemq is failing at startup while creating connection from activemq connection factory

3.3k views Asked by At

In our application we are creating queues by using plain java code below, but sometimes this get failed cause of following error.

I have clue that it fails cause of jar but i have placed all latest jar but still it is failing . Now I have no idea what to do?

Activemq startup code:

            qconFactory = new ActiveMQConnectionFactory("My.Queue");        

            qcon = qconFactory.createConnection(); //error occurs here

            session = qcon.createSession(false, Session.AUTO_ACKNOWLEDGE);

            destination = session.createQueue(QUEUE_NAME);  

            producer = session.createProducer(destination);

            consumer = session.createConsumer(destination);

            msg = session.createTextMessage();

            consumer.setMessageListener(new ImportMessageDrivenBean());
            qcon.start();

Error

javax.jms.JMSException: Could not create Transport. Reason: java.lang.RuntimeException: Fatally failed to create SystemUsageInvalid version: 11, org.apache.activemq.openwire.v11.MarshallerFactory does not properly implement the createMarshallerMap method.

JAR used

activemq-broker-5.15.4.jar

activemq-client-5.15.4.jar

activemq-jaas-5.15.4.jar

activemq-kahadb-store-5.15.4.jar

activemq-openwire-legacy-5.15.4.jar

activemq-protobuf-1.1.jar

geronimo-j2ee-management_1.1_spec-1.0.1.jar

geronimo-jms_1.1_spec-1.1.1.jar

geronimo-jta_1.0.1B_spec-1.0.1.jar

slf4j-api-1.7.25.jar

2

There are 2 answers

2
Tim Bish On

You would get this error if one of the libraries you are using is built using a JDK version that is newer than the one you are running it on. Since that info is not in the question it is hard to guess for sure which one. I'd check that your JDK matches the required version of all the libraries you are using.

The 5.15.x version of ActiveMQ requires JDK 8 so my guess is you are trying to run it on JDK 7 or earlier

0
Richard Jessop On

There are several ActiveMQConnectionFactory ctors available. Without drafting an epistle of completeness, I use the following:

String bindAddress = "failover:tcp://localhost:61616"; // failover promotes resilience URI uRI = new URI(bindAddress); ConnectionFactory factory = new ActiveMQConnectionFactory(uRI); // note the more general ConnectionFactory

The bind address specifies the transport, the host (or IP address), and the port. You can pass a bind address of "tcp://localhost:61616" to the String version of the ctor.