Tomcat7 + JNDI 资源 + IBM WebSphere MQ
Tomcat 7 + JNDI Resource + IBM WebSphere MQ
我的任务是将 Tomcat 7 连接到远程 IBM MQ。我尝试在 server.xml 文件中创建 JNDI 资源,但它不起作用。我使用示例 from.
Addinatinaly 我在这个例子中添加了 username 和 password。但是当我从 java 代码调用 JNDI 资源时出现错误。
<Resource
name="jms/MyQCF"
auth="Container"
type="com.ibm.mq.jms.MQQueueConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="<mymqserver>"
PORT="1414"
CHAN="<mychannel>"
TRAN="1"
QMGR="<myqueuemanager>"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="<myqueue>"/>
我已将所有必需的 *.jars 从 [IBM sphere]/lib/java 下载到 Tomcat lib 文件夹。请帮助我,mb 我做错了。也许我需要一些 IBM 客户端,但我不知道它是什么。
编辑:
错误堆栈跟踪
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
IBM MQ 库的版本是:
Implementation-Version: 7.0.1.8 - k701-108-120201
我在 server.xml 中的当前资源是:
<Resource
name="jms/MyQCF"
auth="Container"
type="org.springframework.jms.connection.CachingConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="192.168.204.73"
PORT="1415"
username="***"
password="***"
CHAN="JAVA.CHANNEL"
TRAN="1"
QMGR="U.SEND"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="U.RECEIVE"/>
我的java代码:
System.out.println("servlet page*****************");
Context ctx = null;
try {
ctx = (Context) new InitialContext().lookup("java:comp/env");
System.out.println("ctx: " + ctx);
} catch (NamingException e) {
e.printStackTrace();
}
QueueConnectionFactory qcf = null;
try {
qcf = (QueueConnectionFactory) ctx.lookup("jms/MyQCF");
System.out.println("qcf: " + qcf);
} catch (NamingException e) {
e.printStackTrace();
}
我的堆栈跟踪:
servlet 页面******************
ctx: org.apache.naming.NamingContext@463b1a3e
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at kz.lalafa.MyServlet.doPost(MyServlet.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
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)
我的 Tomcat lib 文件夹包含:
annotations-api.jar
fscontext.jar
catalina-ant.jar
geronimo-j2ee-management_1.1_spec-1.0.1.jar
catalina-ha.jar
geronimo-jms_1.1_spec-1.1.1.jar
catalina.jar
jasper-el.jar
catalina-tribes.jar
jasper.jar
CL3Export.jar
jms.jar
CL3Nonexport.jar
jndi.jar
com.ibm.mq.commonservices.jar
jsp-api.jar
com.ibm.mq.defaultconfig.jar
jta.jar
com.ibm.mqetclient.jar
ldap.jar
com.ibm.mq.headers.jar
providerutil.jar
com.ibm.mq.jar
rmm.jar
com.ibm.mq.jmqi.jar
servlet-api.jar
com.ibm.mqjms.jar
tomcat-api.jar
com.ibm.mq.jms.Nojndi.jar
tomcat-coyote.jar
com.ibm.mq.pcf.jar
tomcat-dbcp.jar
com.ibm.mq.postcard.jar
tomcat-i18n-es.jar
com.ibm.mq.soap.jar
tomcat-i18n-fr.jar
com.ibm.mq.tools.ras.jar
tomcat-i18n-ja.jar
connector.jar
tomcat-jdbc.jar
dhbcore.jar
tomcat-util.jar
ecj-4.2.2.jar
wmq.jmsra.rar
el-api.jar
我的web.xml:
<?xml version='1.0' encoding='utf-8'?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-env-ref>
<resource-env-ref-name>jms/MyQCF</resource-env-ref-name>
<resource-env-ref-type>javax.jms.QueueConnectionFactory</resource-env-ref-type>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>jms/MyQ</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
</web-app>
我刚决定为此使用 Spring 引导 - https://github.com/lzp4ever/IBM_WebSphere_MQ_Spring_Boot_JMS。
但是我遇到了新问题。我的新问题link:multiple jms connection factory
我的任务是将 Tomcat 7 连接到远程 IBM MQ。我尝试在 server.xml 文件中创建 JNDI 资源,但它不起作用。我使用示例 from.
Addinatinaly 我在这个例子中添加了 username 和 password。但是当我从 java 代码调用 JNDI 资源时出现错误。
<Resource
name="jms/MyQCF"
auth="Container"
type="com.ibm.mq.jms.MQQueueConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="<mymqserver>"
PORT="1414"
CHAN="<mychannel>"
TRAN="1"
QMGR="<myqueuemanager>"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="<myqueue>"/>
我已将所有必需的 *.jars 从 [IBM sphere]/lib/java 下载到 Tomcat lib 文件夹。请帮助我,mb 我做错了。也许我需要一些 IBM 客户端,但我不知道它是什么。
编辑: 错误堆栈跟踪
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
IBM MQ 库的版本是:
Implementation-Version: 7.0.1.8 - k701-108-120201
我在 server.xml 中的当前资源是:
<Resource
name="jms/MyQCF"
auth="Container"
type="org.springframework.jms.connection.CachingConnectionFactory"
factory="com.ibm.mq.jms.MQQueueConnectionFactoryFactory"
description="JMS Queue Connection Factory for sending messages"
HOST="192.168.204.73"
PORT="1415"
username="***"
password="***"
CHAN="JAVA.CHANNEL"
TRAN="1"
QMGR="U.SEND"/>
<Resource
name="jms/MyQ"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
description="JMS Queue for receiving messages from Dialog"
QU="U.RECEIVE"/>
我的java代码:
System.out.println("servlet page*****************");
Context ctx = null;
try {
ctx = (Context) new InitialContext().lookup("java:comp/env");
System.out.println("ctx: " + ctx);
} catch (NamingException e) {
e.printStackTrace();
}
QueueConnectionFactory qcf = null;
try {
qcf = (QueueConnectionFactory) ctx.lookup("jms/MyQCF");
System.out.println("qcf: " + qcf);
} catch (NamingException e) {
e.printStackTrace();
}
我的堆栈跟踪:
servlet 页面******************
ctx: org.apache.naming.NamingContext@463b1a3e
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceEnvFactory.getObjectInstance(ResourceEnvFactory.java:117)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContext.lookup(NamingContext.java:831)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at kz.lalafa.MyServlet.doPost(MyServlet.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
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)
我的 Tomcat lib 文件夹包含:
annotations-api.jar
fscontext.jar
catalina-ant.jar
geronimo-j2ee-management_1.1_spec-1.0.1.jar
catalina-ha.jar
geronimo-jms_1.1_spec-1.1.1.jar
catalina.jar
jasper-el.jar
catalina-tribes.jar
jasper.jar
CL3Export.jar
jms.jar
CL3Nonexport.jar
jndi.jar
com.ibm.mq.commonservices.jar
jsp-api.jar
com.ibm.mq.defaultconfig.jar
jta.jar
com.ibm.mqetclient.jar
ldap.jar
com.ibm.mq.headers.jar
providerutil.jar
com.ibm.mq.jar
rmm.jar
com.ibm.mq.jmqi.jar
servlet-api.jar
com.ibm.mqjms.jar
tomcat-api.jar
com.ibm.mq.jms.Nojndi.jar
tomcat-coyote.jar
com.ibm.mq.pcf.jar
tomcat-dbcp.jar
com.ibm.mq.postcard.jar
tomcat-i18n-es.jar
com.ibm.mq.soap.jar
tomcat-i18n-fr.jar
com.ibm.mq.tools.ras.jar
tomcat-i18n-ja.jar
connector.jar
tomcat-jdbc.jar
dhbcore.jar
tomcat-util.jar
ecj-4.2.2.jar
wmq.jmsra.rar
el-api.jar
我的web.xml:
<?xml version='1.0' encoding='utf-8'?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-env-ref>
<resource-env-ref-name>jms/MyQCF</resource-env-ref-name>
<resource-env-ref-type>javax.jms.QueueConnectionFactory</resource-env-ref-type>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>jms/MyQ</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
</web-app>
我刚决定为此使用 Spring 引导 - https://github.com/lzp4ever/IBM_WebSphere_MQ_Spring_Boot_JMS。
但是我遇到了新问题。我的新问题link:multiple jms connection factory