new MQConnectionFactory() 在 JBoss 中抛出 NullPointerException
我正在尝试执行以下命令:
MQConnectionFactory connFactory = new MQConnectionFactory();
我收到一个空指针异常,但我似乎无法追踪该异常。我在下面附上了堆栈跟踪。
java.lang.NullPointerException
at com.ibm.msg.client.jms.internal.JmsFactoryFactoryImpl.getInstance(JmsFactoryFactoryImpl.java:169)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.setProviderFactory(JmsConnectionFactoryImpl.java:165)
at com.ibm.mq.jms.MQConnectionFactory.<init>(MQConnectionFactory.java:271)
at com.foundation.agent.plugin.JMSClient.createConnection(JMSClient.java:154)
at com.foundation.agent.plugin.JMSClient.launch(JMSClient.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
我正在使用类加载器加载调用 new MQConectionFactory()
的类,因此我怀疑某些 JBoss JMS 库可能导致此问题。
更多信息:
- com.ibm.mq.runtime_7.0.1.0\lib
Jars:
- com.ibm.mq.headers.jar
- com.ibm.mqjms.jar
- jms.jar
- com.ibm.mq.jar
- Connector.jar
- jta.jar
- com.ibm.mq.jmqi.jar
- dhbcore.jar
- providerutil.jar
- com.ibm.mq.pcf.jar
- fscontext.jar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您似乎正在使用 WMQ v7.0.1.0。您是否按照 v7 WMQ 使用 Java 手册?假设采用标准安装,运行时 CLASSPATH 中所需的唯一 jar 是 com.ibm.mqjms.jar。标准安装中有大约 10 个 jar,我在你的列表中没有看到,所以我不确定你是否列出了 CLASSPATH 变量中的内容或 java/lib 中的内容,但这不是我期望的列表。如果您从某处获取了 jar 文件,请尝试使用完整客户端安装
You appear to be using v7.0.1.0 of WMQ. Have you configured your CLASSPATH as described in the v7 WMQ Using Java manual? Assuming a standard install, the only jar you need in the CLASSPATH at runtime is com.ibm.mqjms.jar. There's about 10 jars in the standard install I don't see in your list so I'm not sure if you listed what's in your CLASSPATH variable or what's in the java/lib but it's not the list I'd expect in either case. If you grabbed the jar files from somewhere, try using the full client install
反编译第169行JmsFactoryFactoryImpl的代码,可以看到上面几行有trace输出。在我的系统上,与您遇到的异常相同,系统错误(在我的情况下是 Tomcat 的 catalina.out)上的跟踪输出显示以下内容:
使用该代码,您可以转到:
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.javadoc.doc%2FWMQJMSClasses%2Ferrorcodes.html
Decompiling the code for JmsFactoryFactoryImpl at line 169, you can see that there is a trace output some lines above. On my system with the same Exception as you had, the trace output on system err (Tomcat's catalina.out in my case) revealed the folllowing:
And with that code you can go to:
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/index.jsp?topic=%2Fcom.ibm.mq.javadoc.doc%2FWMQJMSClasses%2Ferrorcodes.html
即使添加了所有必需的 JAR 之后,我也遇到了同样的问题。最后,将我的 JDK 从 IBM JDK 更改为 Oracle/Sun JDK 后问题得到解决。看起来 IBM JDK(独立)没有足够的东西来创建连接工厂。
I faced the same issue even after adding all the required JARs. Finally the issue is resolved after changing my JDK from IBM JDK to Oracle/Sun JDK. looks like IBM JDK (standing alone) doesnt have enough things to create connection factory.