We are using Websphere MQ 7.5 as a messaging solution, using Spring JMS (v4.0.1) we have written a sender class to send some sample messages to this MQ, Now when the spring context is getting initialized it is throwing below ClassNotFoundException exception
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsConnectionFactory' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.ibm.mq.jms.MQQueueConnectionFactory]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1021)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4726)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5162)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.ibm.mq.jms.MQQueueConnectionFactory]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1069)
... 22 more
Caused by: java.lang.NoClassDefFoundError
at com.ibm.msg.client.wmq.factories.WMQFactoryFactory.class$(WMQFactoryFactory.java:132)
at com.ibm.msg.client.wmq.factories.WMQFactoryFactory.setupDistHubTracing(WMQFactoryFactory.java:360)
at com.ibm.msg.client.wmq.factories.WMQFactoryFactory.<init>(WMQFactoryFactory.java:330)
at com.ibm.msg.client.wmq.factories.WMQFactoryFactory.getInstance(WMQFactoryFactory.java:182)
at com.ibm.msg.client.wmq.factories.WMQComponent.getFactoryInstance(WMQComponent.java:138)
at com.ibm.msg.client.jms.internal.JmsFactoryFactoryImpl.getInstance(JmsFactoryFactoryImpl.java:152)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.setProviderFactory(JmsConnectionFactoryImpl.java:176)
at com.ibm.mq.jms.MQConnectionFactory.<init>(MQConnectionFactory.java:285)
at com.ibm.mq.jms.MQQueueConnectionFactory.<init>(MQQueueConnectionFactory.java:76)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
... 24 more
Caused by: java.lang.ClassNotFoundException: com.ibm.disthub2.impl.client.SessionConfig
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
... 38 more
Below is my entry in spring xml
<!-- JMS configuration for Server to send the messages. -->
<bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName" value="${jms.host}" />
<property name="port" value="${jms.port}" />
<property name="queueManager" value="${jms.queueManager}" />
<property name="transportType" value="${jms.transportType}" />
</bean>
<bean id="cachedConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<constructor-arg type="javax.jms.ConnectionFactory" ref="jmsConnectionFactory"/>
<property name="sessionCacheSize" value="20"/>
</bean>
<bean id="senderJMSTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="cachedConnectionFactory"/>
<property name="pubSubDomain" value="false" />
<property name="defaultDestination" ref="senderQueue"/>
</bean>
<bean id="senderQueue" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="${jms.queueName}" />
</bean>
<bean id="jmsSender" class="com.wdpr.payment.util.JMSMessageProducer">
<property name="jmsTemplate" ref="senderJMSTemplate"/>
</bean>
<!-- JMS Configuration ends -->
My Maven entries
Note: This mq jars have been downloaded to our internal maven repo, and we are accessing from there
<!-- Websphere MQ dependencies -->
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq</artifactId>
<version>7.0.1.3</version>
</dependency>
<dependency>
<groupId>com.ibm.mqjms</groupId>
<artifactId>com.ibm.mqjms</artifactId>
<version>7.0.1.3</version>
</dependency>
<dependency>
<groupId>com.ibm.mq.jmqi</groupId>
<artifactId>com.ibm.mq.jmqi</artifactId>
<version>7.0.1.3</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
I tried searching on google but did not find any pointers as to from where and which jar needs to be added to eliminate this error.
This is because you are missing below jar that contains sessionconfig