1

I am following a tutorial about JMS.

package org.dedunu.jms.chapter02;

import javax.jms.ConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.Queue;

public class JMS2Receiver {
    public static void main(String[] args) {
        ConnectionFactory connectionFactory = new com.sun.messaging.ConnectionFactory();
        try(JMSContext jmsContext = connectionFactory.createContext();){
            Queue queue = jmsContext.createQueue("TRADE");
            String body = jmsContext.createConsumer(queue).receiveBody(String.class);
            System.out.println(body);
        }

    }
}

Maven Dependency list:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-core</artifactId>
        <version>5.7.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-ra</artifactId>
        <version>5.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-broker</artifactId>
        <version>5.10.0</version>
    </dependency>
    <dependency>
        <groupId>com.sun.messaging.mq</groupId>
        <artifactId>imq</artifactId>
        <version>4.6-b01</version>
    </dependency>
</dependencies>

But it fails with below exception:

Exception in thread "main" java.lang.AbstractMethodError: com.sun.messaging.ConnectionFactory.createContext()Ljavax/jms/JMSContext;
    at org.dedunu.jms.chapter02.JMS2Sender.main(JMS2Sender.java:10)

If I add jms.jar and imq.jar from OpenMQ distribution, this example works without any problem. But with maven it doesn't. I think problem should be caused by Maven.

dedunu
  • 172
  • 8
  • Do you really want to use JMS 2.0 standalone? have a look at this post: http://www.xenonique.co.uk/blog/?p=1333 – SubOptimal Nov 20 '14 at 11:12
  • I was just trying to redo the samples. :) I talked to the author and he told that OpenMQ 5.0 or later is not available on a maven repository. Thank you ill read the article – dedunu Nov 20 '14 at 14:00

0 Answers0