Search code examples
jmeterjmsibm-mqjndi

jmeter (jms point-to-point) error while connecting IBM - MQ : javax.naming.NoInitialContextException


jmeter (jms point-to-point) error while connecting IBM - MQ :

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory

Need help in resolving the error. FYI: com.ibm.mq.allclient.jar is added in lib folder, 32 bit jdk 1.8

jms point-to-point configuration in jemeter

JNDI configuration in mq explorer

After adding the jars (copied all the MQ Jars (that comes with a complete Websphere MQ installation) and placing them into JMeter/Lib) new error encountered:

Error: Response message: java.lang.IllegalStateException: QueueConnectionFactory expected, but got com.ibm.mq.jms.MQConnectionFactory

Binding file is there in place (C:\Users*****\Downloads\apache-jmeter-3.3\apache-jmeter-3.3\JNDI-Directory)


Solution

  • You do not state which version of IBM MQ jar files you are using, however com.ibm.mq.allclient.jar was introduced in IBM MQ v8, so you must be using v8 or v9.


    The v9 Knowledge Center page "What is installed for IBM MQ classes for JMS" states the following:

    The fscontext.jar and providerutil.jar files are required if your application performs JNDI lookups using a file system context.


    In summary you need to include the following jar files:

    • com.ibm.mq.allclient.jar
    • jms.jar
    • fscontext.jar
    • providerutil.jar

    See my answer to "Upgrade of Java 8 and MQ - NoClassDEfFoundError for more information.


    UPDATE 2018-01-25

    Related to the secondary error:

    Error: Response message: java.lang.IllegalStateException: QueueConnectionFactory expected, but got com.ibm.mq.jms.MQConnectionFactory
    

    In the following answer Attila Repasi addresses the error you are receiving:

    JMeter 3.2 Point-to-Point configuration for IBM MQ 8 => Java Exception

    The answer states:

    Create a MQQueueConnectionFactory in MQExplorer instead of the MQConnectionFactory you have now.

    In addition in the following answer Attila Repasi describes how to configure JMeter with IBM MQ v8 and addresses what to do in MQ Explorer.

    JMeter configuration for IBM MQ 8