4

I've been trying unsuccessfully to get a spring message driven pojo (MDP) to work in a test region (tomcat linux to mq server linux) after it works ok between two dev machines (windows tomcat client to linux server).

Ports and spring configuration seem ok. Trace level logging shows all property values populated correctly. Another war can actually put on the MQ Queue using JMS from this test region tomcat server. This war uses the same tomcat context.xml file that points to the hostname of the MQ server. Resource references in context.xml and web.xml are ok. The listener is set up as described in Getting error : WebSphere MQ reason code 2538?

The exception on the tomcat server comes from com.ibm.mq.jmqi which I understand is a stub to call JNI i.e., native C/C++ code presumably to be installed on the client. I was unclear whether you actually need to install the MQ client when you use JMS. We installed the MQ client but we still get this message. (Reading the docs more thoroughly I think I don't need the MQ Client. In fact, we removed it from the windows client to no ill effect)

I find it odd that the exception is saying that it wants to connect to localhost. The server error files show nothing interesting.

  ****Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host 'localhost(1414)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2538;AMQ9213****


org.springframework.jms.listener.DefaultMessageListenerContainer]
Dec 05 15:22:26 DEBUG org.springframework.jms.listener.DefaultMessageListenerContainer - Could not establish shared JMS Connection - leaving it up to asynchronous invokers to establish a Connection as soon as possible
com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'QMTST' with connection mode 'Client' and host name 'localhost(1414)'.
    at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:479) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:221) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:426) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createV7ProviderConnection(WMQConnectionFactory.java:6902) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6390) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createConnection(JmsConnectionFactoryImpl.java:285) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jms.MQConnectionFactory.createCommonConnection(MQConnectionFactory.java:6233) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:120) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:203) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_24]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_24]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_24]
    at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_24]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) ~[spring-aop-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198) ~[spring-aop-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at $Proxy8.createConnection(Unknown Source) ~[na:na]
    at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184) ~[spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:405) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:373) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:760) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:280) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:265) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:561) [spring-jms-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:167) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:339) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:143) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:108) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:945) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) [spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) [catalina.jar:7.0.29]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) [catalina.jar:7.0.29]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.29]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.29]
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.29]
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) [catalina.jar:7.0.29]
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963) [catalina.jar:7.0.29]
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600) [catalina.jar:7.0.29]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_24]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_24]
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_24]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_24]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_24]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_24]
Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE').
    at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:209) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    ... 45 common frames omitted
**Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host 'localhost(1414)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2538;AMQ9213**: A communications error for  occurred. [1=java.net.ConnectException[Connection refused],3=localhost]],3=localhost(1414),5=RemoteTCPConnection.connnectUsingLocalAddress]
    at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2053) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1226) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiConnect(InterceptedJmqiImpl.java:311) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiConnect(ESEJMQI.java:337) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:346) ~[com.ibm.mqjms-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    ... 44 common frames omitted
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9213: A communications error for  occurred. [1=java.net.ConnectException[Connection refused],3=localhost]
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.connnectUsingLocalAddress(RemoteTCPConnection.java:810) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:1140) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:724) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:400) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:299) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:164) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1598) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    ... 48 common frames omitted
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.6.0_24]
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) ~[na:1.6.0_24]
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) ~[na:1.6.0_24]
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) ~[na:1.6.0_24]
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) ~[na:1.6.0_24]
    at java.net.Socket.connect(Socket.java:529) ~[na:1.6.0_24]
    at java.net.Socket.connect(Socket.java:478) ~[na:1.6.0_24]
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection$5.run(RemoteTCPConnection.java:795) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection$5.run(RemoteTCPConnection.java:789) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_24]
    at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.connnectUsingLocalAddress(RemoteTCPConnection.java:787) ~[com.ibm.mq.jmqi-7.5.jar:7.5.0.2 - p750-002-130704.TRIAL]
Community
  • 1
  • 1
user1069528
  • 618
  • 1
  • 13
  • 29

2 Answers2

2

We found out that it's picking up localhost from the MQ file based JNDI bindings file. It looks like a hack but we just change localhost in the .bindings file to the IP of the MQ server and then things work.

It never looks at the Tomcat context.xml file once it has found a QMGR matching name in the .bindings file.

user1069528
  • 618
  • 1
  • 13
  • 29
0

The exception clearly shows application is trying to connect to a queue manager on the same machine. It means your configuration is not correct. You must edit the configuration file to provide host name and port number.

Btw MQ JMS does not use native c libraries when connecting in clients (over a TCP socket) mode. It's all Java.

Shashi
  • 14,980
  • 2
  • 33
  • 52
  • Yes but the configuration is set in tomcat with the context.xml file which applies for all apps. The hostname is set in a resource entry there and it is used successfully by the other app putting to the queue. The web.xml for the listener has queue destinations that point to resources in that context.xml. And again this works on dev machines. – user1069528 Dec 07 '13 at 20:55
  • On development machines the configuration could be working because both Tomcat and WebSphere MQ queue manager are on the same machine. Now on the machine where the problem occurs, is the queue manager running on the same machine as Tomcat? – Shashi Dec 08 '13 at 00:28
  • They are on different machines. Discussing configuration with you made me think that I'm not 100% sure that context.xml is in the same place on the test Tomcat machine. I understood it was. I'll ask tomorrow. If the second app is not picking up global resource settings for jndi that might explain a default call to localhost. – user1069528 Dec 08 '13 at 16:32
  • The context.xml is where it should be in both environments: in the conf folder. – user1069528 Dec 09 '13 at 13:22
  • We figured it out. It's getting the localhost from the MQ file based binding file instead of tomcat jndi resource config. – user1069528 Dec 16 '13 at 15:34