0
votes

Way 1 : Third-party messaging provider

I use Websphere application Server 8.5.5 and I configured the queue by creating
my JMS provider as mentioned in the link1 and link2

(In classpath :where I used fscontext jar and required required ibm jms jars and ). QueueConnectionFactory with my jms provider.

In application I use jms to put meesages to the queue.

  @Resource(lookup = "jms/ConnectionFactory")
  private static QueueConnectionFactory connectionFactory;

  @Resource(lookup = "jms/Queue")
  private static Queue queue;

  public void putMessagesToQueue() {                                                                   
  try {
     // create a queue connection
     QueueConnection queueConn = connFactory.createQueueConnection();
     ......... 
  } catch(JMSException exp) {
       // Handle this exception
   } finally {      
        if(queueConn != null) {                                                     
             // close the queue connection
            queueConn.close();
        } else {
          System.out.println("Queue connection is null");
        }
   }

I get the below exception at line connFactory.createQueueConnection(). I see the sysout in final block is getting printed as "Queue connection is null".

Exception :

javax.jms.JMSException: Failed to create queue connection
    at com.ibm.ejs.jms.JMSCMUtils.mapToJMSException(JMSCMUtils.java:140) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle.createQueueConnection(JMSQueueConnectionFactoryHandle.java:91) ~[com.ibm.ws.runtime.jar:na]

getLinkedException()=javax.resource.spi.ResourceAllocationException: Expected QueueConnectionFactory

Caused by: java.lang.ClassCastException: com.ibm.mq.jms.MQConnectionFactory incompatible with javax.jms.QueueConnectionFactory
    at com.ibm.ejs.jms.JMSManagedQueueConnection.createConnection(JMSManagedQueueConnection.java:157) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.jms.JMSManagedConnection.<init>(JMSManagedConnection.java:352) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.jms.JMSManagedQueueConnection.<init>(JMSManagedQueueConnection.java:72) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.jms.GenericJMSManagedQueueConnectionFactory.createManagedConnection(GenericJMSManagedQueueConnectionFactory.java:92) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.jms.JMSManagedConnectionFactory.createManagedConnection(JMSManagedConnectionFactory.java:687) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.FreePool.createManagedConnectionWithMCWrapper(FreePool.java:2160) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1838) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3816) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3092) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1548) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1031) ~[com.ibm.ws.runtime.jar:na]
    at com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle.createQueueConnection(JMSQueueConnectionFactoryHandle.java:85) ~[com.ibm.ws.runtime.jar:na]

Way 2 : WebSphere MQ messaging provider

I used the same code in application to put messages to queue but with different provider which is (WebSphere MQ messaging provider ) and created queue Connection factory with that provider and Queue manager, hostname, port and all details I have added in QueueConnectionFactory.

In this case I see I don't see any error and I'm successfully able to write in to the queue.

Question :

Why is it not working in way 1? I need to work in way 1 not in way 2.

1
Why can't you use the WebSphere MQ messaging provider? That is the supported way to configure WAS access to MQ.Alasdair
It is suggested inmy requirement to use the way1 and not to use WebSphere MQ messaging provider. Any idea why it is not working in way1,please??Alagammal P
So what JMS provider do you want to use? Do you have the JARs for that on the classpath?Attila Repasi
I want to use the one described in way 1 and I also added all the jars in the classpathAlagammal P
I get that you want to use way 1, but if you are talking to IBM MQ why do you have a requirement to use an unsupported mechanism for doing so rather than a fully supported one?Alasdair

1 Answers

1
votes

Based on comments from OP @AlagammalP, non-IBM MQ supplied providerutil.jar and fscontext.jar were added to the class path.

WAS (Websphere Application Server) comes with the IBM MQ resource adapter included which includes these.

Remove the non-IBM MQ supplied providerutil.jar and fscontext.jar that were added to the class path as they are causing your issue:

Caused by: java.lang.ClassCastException: com.ibm.mq.jms.MQConnectionFactory incompatible with javax.jms.QueueConnectionFactory