Java – Connecting to IBM MQ from Java client is failing with MQJE001: Completion Code ‘2’, Reason ‘2035’

ibm-mqjava

I have a IBM MQ version 7.5 installation in windows 7. I have created a queue manager, channel and listener using the following commands.

//CREATE THE QUEUE MANAGER
crtmqm.exe PG3RT1

//START THE QUEUE MANAGER AS INTERACTIVE
strmqm.exe -si PG3RT1

//CONNECT AS SCRIPT CONSOLE
runmqsc.exe PG3RT1

//CREATE THE CHANNEL TO APPLICATION CONNECTIVITY
DEFINE CHANNEL(PG3RT1.CHANNEL) CHLTYPE(SVRCONN) TRPTYPE(TCP)

//CREATE THE LISTENER 
DEFINE LISTENER(LISTENER.PG3RT1) TRPTYPE(TCP) PORT(1414)

//START THE LISTENER
START LISTENER(LISTENER.PG3RT1)

Now i am trying to connect to the Queue Manager using following java client.
connection is rejected with the following error.

    15:06:52.175 [localhost-startStop-1] ERROR c.b.c.s.s.m.MQUtil - MQJE001: Completion Code '2', Reason '2035'.
com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2035'.
        at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:230)
        at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:553)
        at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:593)
        at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:96)
        at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:198)
        at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:893)
        at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:780)
        at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:729)
        at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:177)
        at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:745)
        at com.bcs.cas.sach.simulator.mq.MQUtil.init(MQUtil.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)

Can anyone advise why the connection is failing.
Do i need to enable remote administration on the queue manager?

Following is the code fragement i used for connection

public void init(){
    MQEnvironment.hostname = hostName;
    MQEnvironment.port = Integer.valueOf(port);
    MQEnvironment.channel = serverChannelName;
    MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);
    LOGGER.info("queueManagerName: " + queueManagerName);
    LOGGER.info("hostName: " + hostName);
    LOGGER.info("serverChannelName: " + serverChannelName);
    LOGGER.info("port: " + port);
    //initialize the connection pool
    MQPoolToken token = MQEnvironment.addConnectionPoolToken();
    try {
        mqQueueManager = new MQQueueManager(queueManagerName, MQEnvironment.properties);
        LOGGER.info("mqQueueManager: " + mqQueueManager);
    } catch (MQException e) {
        LOGGER.error(e.getMessage(), e);
    }
}

Best Answer

MQRC 2035 is MQRC_NOT_AUTHORIZED. The reason this was returned can be found in the AMQERR log on the queue manager.

As CHLAUTH hasn't been configured, and is on by default, I expect you're not able to connect as you're not passing the CHLAUTH rules.

Related Topic