Reputation: 21
Hi I am trying to connect WebSphere IBM MQ 7.5.0.7 Connection factory from Tomcat 8. While starting tomcat server we load spring XML, from that we connect to IBM MQ Connection factory.
Below is the code in spring xml.
<bean name="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/JMS/QFX_PF1UATMQCF" />
</bean>
Below code in Context.xml in Tomcat.
<Resource name="JMS/QFX_PF1UATMQCF"
auth="Container"
type="com.ibm.mq.jms.MQQueueConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="some hostname"
PORT="1425"
CHAN="SYSTEM.DEF.SVRCONN"
TRAN="1"
QMGR="EUQFXP7A"/>
Below is the exception i am getting while starting tomcat.
Cannot resolve reference to bean 'jmsConnectionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsConnectionFactory' defined in class path resource : Invocation of init method failed; nested exception is javax.naming.NamingException: Could not create resource factory instance [Root exception is java.lang.NoClassDefFoundError: javax/jms/JMSException]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
Upvotes: 2
Views: 2974
Reputation: 2199
You need to copy at least the following JAR files to Tomcat (e.g. $CATALINA_BASE/lib
):
As @JoshMc mentioned, you should not use MQ 7.5 anymore.
When starting Tomcat, you may see WARNING
messages in catalina.log
like this:
24-Feb-2018 22:06:40.473 WARNING [localhost-startStop-1] org.apache.tomcat.util.scan.StandardJarScanner.processURLs Failed to scan [file:.../lib/jms.jar] from classloader hierarchy
java.io.FileNotFoundException: .../lib/jms.jar (The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
You can eliminate these warnings by adding the MQ jar to tomcat.util.scan.StandardJarScanFilter.jarsToSkip
property in catalina.properties
.
Upvotes: 1