2

We have upgraded to IBM MQ8 and have following dependencies in our project. The following dependencies exists

com.ibm.disthub2.dhbcore
com.ibm.mq.jmqi
com.ibm.mqjms
ibm-jaxrpc-client
com.ibm.mq
com.ibm.mq.headers
com.ibm.mq.pcf
com.ibm.mq.commonservices

However while running the main program, it is giving NoDefFoundError, despite of providing the jars in the classpath.

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.ibm.mq.headers.internal.HeaderType
        at com.ibm.mq.headers.pcf.PCFMessage.<init>(PCFMessage.java:77) ~[com.ibm.mq.headers-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.headers.pcf.PCFMessage.<init>(PCFMessage.java:132) ~[com.ibm.mq.headers-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.ese.service.PolicyServiceImpl.policyFromPcf(PolicyServiceImpl.java:575) ~[com.ibm.mq.jmqi-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.ese.intercept.JmqiOpenInterceptorImpl.storeSecurityInfoInSmqiObject(JmqiOpenInterceptorImpl.java:359) ~[com.ibm.mq.jmqi-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.ese.intercept.JmqiOpenInterceptorImpl.readPolicyIfAvailable(JmqiOpenInterceptorImpl.java:321) ~[com.ibm.mq.jmqi-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.ese.intercept.JmqiOpenInterceptorImpl.afterSpiOpen(JmqiOpenInterceptorImpl.java:203) ~[com.ibm.mq.jmqi-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.spiOpen(InterceptedJmqiImpl.java:411) ~[com.ibm.mq.jmqi-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.ese.jmqi.ESEJMQI.spiOpen(ESEJMQI.java:513) ~[com.ibm.mq.jmqi-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.msg.client.wmq.internal.WMQMessageProducer$SpiIdentifiedProducerShadow.initialise(WMQMessageProducer.java:762) ~[com.ibm.mqjms-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.msg.client.wmq.internal.WMQMessageProducer.<init>(WMQMessageProducer.java:995) ~[com.ibm.mqjms-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.msg.client.wmq.internal.WMQSession.createProducer(WMQSession.java:889) ~[com.ibm.mqjms-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.msg.client.jms.internal.JmsSessionImpl.createProducer(JmsSessionImpl.java:1232) ~[com.ibm.mqjms-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.msg.client.jms.internal.JmsQueueSessionImpl.createSender(JmsQueueSessionImpl.java:136) ~[com.ibm.mqjms-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.jms.MQQueueSession.createSender(MQQueueSession.java:153) ~[com.ibm.mqjms-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at com.ibm.mq.jms.MQQueueSession.createProducer(MQQueueSession.java:254) ~[com.ibm.mqjms-7.5.0.6.jar:7.5.0.6 - p750-006-160226]
        at org.springframework.jms.core.JmsTemplate.doCreateProducer(JmsTemplate.java:1114) ~[spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
        at org.springframework.jms.core.JmsTemplate.createProducer(JmsTemplate.java:1095) ~[spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.doSendToDestination(JmsConfiguration.java:482) ~[camel-jms-2.17.0.jar:2.17.0]
        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.access$100(JmsConfiguration.java:428) ~[camel-jms-2.17.0.jar:2.17.0]
        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate$1.doInJms(JmsConfiguration.java:442) ~[camel-jms-2.17.0.jar:2.17.0]
        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:484) ~[spring-jms-4.3.4.RELEASE.jar:4.3.4.RELEASE]
JoshMc
  • 10,239
  • 2
  • 19
  • 38
IMahajan
  • 53
  • 3
  • 13
  • Be mindful of the fact that NoClassDefFoundError is not quite the same as a ClassNotFoundException. What this is saying that there was a previous exception or error that interrupted the correct initialization of the HeaderType class. This may be a classpath issue or it might be something else entirely. As said by JoshMC - the allclient.jar is a better option. Also be aware that as you are using Spring + Camel the classloading might be different than a JavaSE application. – Calanais Feb 11 '17 at 22:57
  • To piggyback on that last comment, I'd suggest searching your log files for "clinit" - the "Could not initialize class" message indicates that the class failed static initialization, so chances are that there's an exception somewhere with HeaderType. in the stack trace. – Jarid Feb 12 '17 at 04:05

2 Answers2

2
  1. Did you upgrade the MQ server to v8 or the MQ client to v8 or both?
  2. Do they run on the same machine?
  3. The stack trace shows all of the jar files have been renamed to include the string 7.5.0.6 which would indicate that they are from a MQ v7.5.0.6 MQ client install. IBM does not support moving the jar files from the standard installation location prior to v8.0.
  4. At MQ v8.0 and later IBM provides a java only install that can be located anywhere.
  5. At MQ v8.0 and later IBM also allows relocation of the files com.ibm.mq.allclient.jar and com.ibm.mq.traceControl.jar from a full client or server install to other servers and locations in the same enterprise, the above files contain all of the classes that were previously in separate jar files.

It would be recommended to remove all the jar files with 7.5.0.6 from the name and stick with the two jar files provided by IBM with MQ v8.0.

Per OP @IMahajan, the following components were upgraded: Spring, Camel, Java and all related jars including JMS.

JoshMc
  • 10,239
  • 2
  • 19
  • 38
0

Many thanks for your input. I found the resolution was version of the jar. I provided the higher version of com.ibm.mq.headers(containing HeaderType.Class)to V8 and provided it in the class path. It worked. I think mq8 is not compatible with v7.5.0.6. Please update if you feel different.

IMahajan
  • 53
  • 3
  • 13
  • Removed all files with 7.5.0.6 and added v8. But now its giving "Caused by: java.lang.NoClassDefFoundError: javax/jms/JMSRuntimeException at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.8.0_92] Caused by: java.lang.ClassNotFoundException: javax.jms.JMSRuntimeException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_92] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_92] at " – IMahajan Feb 13 '17 at 13:03
  • Thanks , I got it working .As per your recommendation I removed all other jars and kept only two as mentioned by you. It also required JMS upgrade , after which it is working fine – IMahajan Feb 14 '17 at 10:08
  • Yes,it was spring and camel. It was spring,camel,java upgrade and hence all related jars including JMS. I have already voted for your answer – IMahajan Feb 14 '17 at 17:52