ibm-messaging / mq-jms-spring

Components to assist MQ JMS integration with Spring frameworks
Apache License 2.0
190 stars 102 forks source link

Authentication failure , The specified userid is not used on connections #48

Closed JakesIV closed 4 years ago

JakesIV commented 4 years ago

Please include the following information in your ticket.

@JmsListener(destination = "HUB.SPRINGBOOT.SND") public void onAuditMessage(final Message receivedMessage) { if (receivedMessage instanceof BytesMessage) { BytesMessage bytesMessage = (BytesMessage) receivedMessage; byte[] bytesreceived; try { bytesreceived = new byte[(int) bytesMessage.getBodyLength()]; bytesMessage.readBytes(bytesreceived); MQMessage mqMsg = new MQMessage(); mqMsg.write(bytesreceived); mqMsg.encoding = receivedMessage.getIntProperty(WMQConstants.JMS_IBM_ENCODING); mqMsg.format = receivedMessage.getStringProperty(WMQConstants.JMS_IBM_FORMAT); String codePage = receivedMessage.getStringProperty(WMQConstants.JMS_IBM_CHARACTER_SET);

    mqMsg.seek(0);
    log.info("message len " + Integer.toString(mqMsg.getMessageLength()));
    log.info("message encoding " + Integer.toString(mqMsg.encoding));
    log.info("message format " + mqMsg.format);
    log.info("message type " + Integer.toString(mqMsg.messageType));
    log.info("message code page " + codePage);

    try {
        log.info("message content:  " + mqMsg.readStringOfByteLength(mqMsg.getMessageLength()));
    } catch (Exception e) {
        log.info("No message content : " + e.getMessage());
    }

    } catch (JMSException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }
} else if (receivedMessage instanceof TextMessage) {
    TextMessage txtMessage = (TextMessage) receivedMessage;
    log.info("Text message received");
    try {
    log.info(txtMessage.getText());
    } catch (JMSException e) {
    e.printStackTrace();
    }
} else {
    log.info("Not valid message format");
    log.info(receivedMessage.getClass().getName());
    log.info("================");
}

}

Error received Could not refresh JMS Connection for destination 'HUB.SPRINGBOOT.SND' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: JMSWMQ2013: The security authentication was not valid that was supplied for queue manager 'QMNAME' with connection mode 'Client' and host name 'SERVERNAME(1415)'.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2035' ('MQRC_NOT_AUTHORIZED').

When looking at the logs it is trying to authoirse using the userid the app is running on and not the one specified in the properties file. what are we doing wrong???

ibmmqmet commented 4 years ago

What is the exact message in the qmgr error log? You say it's "trying to authorise" but you also write "authentication" failure in the issue title. I suspect you don't have the ADOPTCTX value set on the AUTHINFO object on the qmgr so that the authentication of the specified userid is OK and it's failing later on the authorisation phase. See https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.1.0/com.ibm.mq.sec.doc/q113250_.htm

ibmmqmet commented 4 years ago

Closing as no recent updates