简体   繁体   中英

No clue with an exception (NullPointerException) due to a properties retrieval thrown by the IBM MQ

I'm having this exception thrown by the IBM MQ which I'm struggling with, I have no clue why this is happening. Here it comes:

java.lang.NullPointerException
    at com.ibm.mq.jmqi.JmqiEnvironment.getVersionProperty(JmqiEnvironment.java:2204)
    at com.ibm.mq.jmqi.JmqiEnvironment.getProductIdentifier(JmqiEnvironment.java:2224)
    at com.ibm.mq.jmqi.remote.internal.system.RemoteConnection.initSess(RemoteConnection.java:1388)
    at com.ibm.mq.jmqi.remote.internal.system.RemoteConnection.connect(RemoteConnection.java:1078)
    at com.ibm.mq.jmqi.remote.internal.system.RemoteConnectionPool.getConnection(RemoteConnectionPool.java:338)
    at com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiConnect(RemoteFAP.java:1488)
    at com.ibm.mq.MQSESSION.MQCONNX_j(MQSESSION.java:915)
    at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:224)
    at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:505)
    at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:547)
    at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:95)
    at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:182)
    at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:869)
    at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:761)
    at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:712)
    at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:171)
    at com.ibm.mq.MQQueueManager.(init)(MQQueueManager.java:597)
    at mytestpackage.MyTestClass.(init)(MyTestClass.java:143)
    . . .

I'm having two scenarios, (1) A stand-alone one-threaded app which runs okay (jre6), but I'm having troubles when I use this (2) as part of a library used by a multi-core environment (using the 1.4.2 JVM).

Reproduced Code

MQEnvironment.hostname = Host;
MQEnvironment.channel = Channel;
MQEnvironment.port = Port;
MQEnvironment.userID = QMUser;
MQEnvironment.password = QMPass;

MQQueueManager qmanager = new MQQueueManager(QueueManager);
MQMessage mqmessage = new MQMessage();
MQPutMessageOptions mqputmessageoptions = new MQPutMessageOptions();
MQQueue mqqueue = qmanager.accessQueue(QueueReq, 8208, null, null, null);

mqmessage.format = MQC.MQFMT_STRING;
mqmessage.persistence = 1;
mqmessage.replyToQueueName = QueueResp;
mqmessage.expiry = -1;
mqmessage.priority = -1;
mqmessage.writeString(MWAS);
mqmessage.messageId = "".getBytes();
mqmessage.correlationId = "".getBytes();

mqqueue.put(mqmessage, mqputmessageoptions);

mqqueue.close();

The execution doesn't even get to the instantiation of the MQQueueManager , the exception is thrown when assigning the MQEnvironment 's static attributes.

Extra Info

The running OS is Windows 2003 Server R2 Enterprise SP2 (x64). The JVM is the Sun's 1.4.2_10 (x86). The WMQ version is 7.0.1.5. Some system properties are: , , .

Deepest Exception

java.lang.ExceptionInInitializerError
    at com.ibm.msg.client.commonservices.cssystem.WASSupport.<clinit>(WASSupport.java:39)
    at com.ibm.mq.internal.MQCommonServices$6.run(MQCommonServices.java:1263)
    at com.ibm.mq.internal.MQCommonServices$Helper.runIgnoresNoClass(MQCommonServices.java:1322)
    at com.ibm.mq.internal.MQCommonServices.isJmsCommonServicesRequired(MQCommonServices.java:1277)
    at com.ibm.mq.internal.MQCommonServices.<clinit>(MQCommonServices.java:265)
    at com.ibm.mq.MQSESSION.getJmqiEnv(MQSESSION.java:134)
    at com.ibm.mq.MQSimpleConnectionManager.<init>(MQSimpleConnectionManager.java:93)
    at com.ibm.mq.MQEnvironment.<clinit>(MQEnvironment.java:574)
    at mytestpackage.MyTestClass.(init)(MyTestClass.java:143)
Caused by: java.security.AccessControlException: access denied (java.util.logging.LoggingPermission control)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
    at java.security.AccessController.checkPermission(AccessController.java:546)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    at java.util.logging.LogManager.checkAccess(LogManager.java:930)
    at java.util.logging.Logger.checkAccess(Logger.java:255)
    at java.util.logging.Logger.setLevel(Logger.java:1131)
    at com.ibm.msg.client.commonservices.j2se.trace.DefaultTracer$8.run(DefaultTracer.java:1581)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.ibm.msg.client.commonservices.j2se.trace.DefaultTracer.setTraceLevel(DefaultTracer.java:1578)
    at com.ibm.msg.client.commonservices.trace.Trace.setTraceLevel(Trace.java:408)
    at com.ibm.msg.client.commonservices.trace.Trace.initialize(Trace.java:2027)
    at com.ibm.msg.client.commonservices.trace.Trace.<clinit>(Trace.java:323)
    ... 17 more

What could this be?

Thank you in advance.

Most likely this happens, when you try to access a data structure [which is not synchronized inside] with multiple threads without a lock.

One of the object you are accessing in the stack trace is not multi threadble and you need a lock.

One example being HashMap [as against hashtable] - try to use it with multiple threads without a lock outside.

What do you mean by the "the 1.1.0 MS JVM"? I can see from the stack trace that you're using the v7 MQ client - the JVM requirements are listed here

http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg27011920

Assuming you're 32-bit, the supported options are

Java 2 Platform, Standard Edition (J2SE) V1.4.2 from Sun Microsystems, Inc. 
Java 2 Platform, Standard Edition V5.0 (SR1 or above) from Sun Microsystems, Inc. 
Java 2 Platform, Standard Edition V6.0 from Sun Microsystems, Inc. 
IBM 32-bit SDK for Windows, Java 2 Technology Edition, V1.4.2 
IBM 32-bit SDK for Windows, Java 2 Technology Edition, V5.0 (SR1 or above) 
IBM 32-bit SDK for Windows, Java Technology Edition, V6.0 

So I suspect that the code is throwing a NullPointerException because an unsupported JVM is unexpectedly returning null when the WMQ Java client is querying a system property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM