messaginghub / pooled-jms

A JMS Connection pool for messaging applications supporting JMS 1.1 and 2.0 and Jakarta JMS clients
Apache License 2.0
49 stars 25 forks source link

java.lang.NoSuchMethodError: javax.jms.MessageProducer.getDeliveryDelay() #9

Closed tmccore closed 6 years ago

tmccore commented 6 years ago

Using the latest tag 1.0.0, we get this error when executing the following code:

JmsPoolConnectionFactory poolingFactory = new JmsPoolConnectionFactory(); poolingFactory.setConnectionFactory(createArtemisConnectionFactory()); TopicConnection topicConnection = poolingFactory.createTopicConnection(); TopicSession topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); Topic topic = ic.lookup("topicname"); TopicPublisher topicPublisher = topicSession.createPublisher (topic); <- throws exception

java.lang.NoSuchMethodError: javax.jms.MessageProducer.getDeliveryDelay()J at org.messaginghub.pooled.jms.JmsPoolMessageProducer.(JmsPoolMessageProducer.java:64) at org.messaginghub.pooled.jms.pool.PooledSessionHolder.getOrCreateProducer(PooledSessionHolder.java:144) at org.messaginghub.pooled.jms.JmsPoolSession.createProducer(JmsPoolSession.java:426)

We are using Artemis version 2.4.0.

tabish121 commented 6 years ago

There is a suite of Artemis integration tests where you can find examples for writing a unit test to reproduce this so that it can be investigated

tmccore commented 6 years ago

Here's the unit test method that you can place in PooledConnectionFactoryTest.java

@Test(timeout = 60000)
public void testTopicMessageSend() throws Exception {
    cf.setMaxConnections(1);

    TopicConnection conn = (JmsPoolConnection) cf.createTopicConnection();
    TopicSession topicSession = conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
    Topic t = new Topic() {
        @Override
        public String getTopicName() throws JMSException {
            // TODO Auto-generated method stub
            return null;
        }
    };
    TopicPublisher topicPublisher = topicSession.createPublisher(t);
    topicPublisher.send(null);
    assertEquals(1, cf.getNumConnections());
    cf.stop();
}

And it will give you the aforementioned error.

You will need the following imports as well:

import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.QueueConnectionFactory; import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicConnection; import javax.jms.TopicConnectionFactory; import javax.jms.TopicPublisher; import javax.jms.TopicSession;

tabish121 commented 6 years ago

It appears you have the JMS 1.1 API Jar on the classpath instead of the JMS 2.0 API needed for Artemis

tabish121 commented 6 years ago

Either replace the JMS Jar currently on the classpath with a 2.0 variant or update to Pooled-JMS v 1.0.1 and that should fix your issue.

tmccore commented 6 years ago

Thanks that worked.