views:

54

answers:

1

I am trying to execute the following command

MQConnectionFactory connFactory = new MQConnectionFactory();

and i get a null pointer that i can't seem to track down, i have attached the stack trace, any help would be greatly appreciated.

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.(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)

i am loading the class that calls the new MQConectionFactory() using a class loader so i suspect that some jboss JMS lib possibly causing this.

more info:

  • 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
+1  A: 

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

T.Rob
I am not trying to use XA functionality, I am not sure that i am using a resource adapter because i am not defining or deploying and EJBs.Basically i am starting a thread within jboss that will build out the connection using the connection factory...it seems to me, and i could be mistaken, that some jms property its causing the MQConnectionfactory to try to instantiate itself as an XA transaction factory which i don't have the license to do.that being said i am not sure what or how to overide this...
jesse reim
i only listed the jars that i added from the IBM/WebSphere MQ/eclipse/plugins/com.ib.mq.runtime_7.0.1.0/lib that i needed, is there some other jar that i should be including that may be causing jboss to default to something other then what i want?
jesse reim
Grabbing the jars from the WMQ Explorer install may or may not work. WMQ Explorer bundles specific functionality it needs and may use non-public API calls. If you can get it to work that way in dev, go for it. However for Production I would install nothing less than the full WMQ client as linked in my response. This is the configuration IBM will support and includes things like tracing, diagnostics and sample utilities you can use to test your install. Even if you don't necessarily want these, IBM may need them if you open a support incident.
T.Rob
When you define the connection factory you can choose which type to define. It can be a CF, TCF, QCF, XACF, XAQCF or XATCF. If you are instantiating the object in the code, this depends on the environment you set up prior to the API call. If you do this in JNDI it depends on the JNDI object definition. Once you install the full client code and include the dev kit option, there are sample programs both with and without JNDI lookup.
T.Rob
Rob, first off thanks for the help! So heres my hang up with using JNDI, i cant get past the new MQConnectionFactory(). How would using JNDI get around the fact that i cant new it? wouldn't the properties still be incorrect causing the null pointer? (If i am wrong please let me know) also so you have a bit more context i am trying to run a client only to connect to a third party who is hosting the MQ server, should i really still have to do that full install everywhere?
jesse reim
Sorry, I'm not saying that you should be using JNDI, just responding to your first comment about XA vs non-XA. These don't come into play until after you create the CF object, just as you note here. As for whether you need to install the full client, nearly all of the issues that I've run into running WMQ client end up being configuration and install. Continued next comment...
T.Rob
I'd suggest start with the textbook installation as described in the WMQ Clients Manual and the Using Java manual linked above and run the Initial Verification Test (IVT). Once you've done that successfully if you want to deviate from that do it one step at a time and test until you know where it breaks. Keep in mind that if you ever want to open a support ticket on this, the full client install is the only one supported.
T.Rob
I figured that i would follow up with this. The issue was with MQ not jiving with jboss. MQ.7.0.1.1 failed but MQ.6.0.2.9 worked. I was using jboss4.0.4.
jesse reim
Ah, that's too bad. All the v6.x WMQ stuff will be out of support in September 2011 and v7 has so much better JMS support. Try to migrate as soon as you can. Glad to hear you got it going, though.
T.Rob