can not get an an MQ MDB to work in Liberty - ibm-mq

I have a sample Java program that works. I try to put the same credentials / queue data into the MDB and I get
Caused by: com.ibm.msg.client.jms.DetailedJMSSecurityException: JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'QueueMgr1' with connection mode 'Client' and host name 'queuemgr1.....'.
Please check if the supplied username and password are correct on the QueueManager to which you are connecting.
This is happening in Open Liberty and WAS Liberty.
this is my config
<resourceAdapter id="mq" location="/config/wmq.jmsra.rar" />
<jmsActivationSpec id="Messaging/MessagingEJB/MessagingMDB" authDataRef="MQCredentials" maxEndpoints="1">
<properties.mq
transportType="CLIENT"
hostName="${env.MQ_HOST}"
port="${env.MQ_PORT}"
channel="${env.MQ_CHANNEL}"
queueManager="${env.MQ_QUEUE_MANAGER}"
destinationRef="NotificationQ"
destinationType="javax.jms.Queue" />
</jmsActivationSpec>
<jmsQueue id="NotificationQ" jndiName="jms/StockTrader/NotificationQueue">
<properties.mq baseQueueName="${env.MQ_QUEUE}" baseQueueManagerName="${env.MQ_QUEUE_MANAGER}" />
</jmsQueue>

Related

SpringBoot and IBM MQ connection properties not overrided on deploy

I've a SpringBoot App with a local configuration to connect and listen a local Queue
ibm:
mq:
queueManager: LOCAL_QM
channel: DEV.ADMIN.SVRCONN
connName: localhost(1414)
user: admin
password: passw0rd
user-authentication-m-q-c-s-p: false
When a I deploy the app with Gitlab CI some properties are overrided (with a war_name.xml file in ../tomcat/current/conf/Catalina/localhost/) like database connection properties and mq connection properties to listen a Developpement or Qualification environment queue.
But when the app start the database connection is OK but not the MQ connection (The app use the local connection properties defined in the application.yml file)
When I check the xml file on the remote server, the properties are override.
And when I use a tool like spring actuator, I have the right properties override with the specific env properties.
But in the logs: /tomcat/current/logs/catalina.out I can read that the app try to connect to the local queue manage : LOCAL_QM not the specific environment queue.
2021-05-11 12:19:23.484 ERROR 14483 --- [ntContainer#0-1] o.s.j.l.DefaultMessageListenerContainer : Could not refresh JMS Connection for destination '***' - retrying using FixedBackOff{interval=5000, currentAttempts=16093, maxAttempts=unlimited}. Cause: JMSWMQ0018: Failed to connect to queue manager 'LOCAL_QM' with connection mode 'Client' and host name 'localhost(1414)'.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE')
The properties are in the same xml file, it works for the database "spring.datasource" but not for MQ "ibm.mq"
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Environment name="spring.datasource.url" value="jdbc:postgresql://***:5432/**" type="java.lang.String"/>
<Environment name="spring.datasource.username" value="****" type="java.lang.String"/>
<Environment name="spring.datasource.password" value="****" type="java.lang.String"/>
<Environment name="ibm.mq.queueManager" value="***" type="java.lang.String"/>
<Environment name="ibm.mq.channel" value="***" type="java.lang.String"/>
<Environment name="ibm.mq.connName" value="***" type="java.lang.String"/>
<Environment name="ibm.mq.user" value="***" type="java.lang.String"/>
<Environment name="ibm.mq.password" value="" type="java.lang.String"/>
</Context>
Any idea why the properties are not overrided ?
Thanks
This started out as a comment, but as I wrote it I suspected that you are missing the relevant ibm.mq properties. If you don't provide the following properties:
ibm.mq.queueManager
ibm.mq.channel
ibm.mq.connName
ibm.mq.user
ibm.mq.password
then they default to
ibm.mq.queueManager=QM1
ibm.mq.channel=DEV.ADMIN.SVRCONN
ibm.mq.connName=localhost(1414)
ibm.mq.user=admin
ibm.mq.password=passw0rd
ie. localhost.
The mq-jms-spring-boot-starter makes use of
import org.springframework.boot.context.properties.ConfigurationProperties;
#ConfigurationProperties(prefix = "ibm.mq")
to read the connection properties. In this module https://github.com/ibm-messaging/mq-jms-spring/blob/master/mq-jms-spring-boot-starter/src/main/java/com/ibm/mq/spring/boot/MQConfigurationProperties.java
So it relies on spring to make the properties prefixed with ibm.mq available to it. ie. As long as spring through #ConfigurationProperties knows how to handle the overrides it will make them available to mq-jms-spring-boot-starter.

IBM Liberty 19.0.0.11 return CWWKO0801E: Unable to initialize SSL connection

I have added restConnector-2.0 feature in Liberty 19.0.0.11.
I changed configuration in server.xml file like below,
<basicRegistry id="bas" relam="BasicRealm">
<user name="kin" password="password"/>
<group name="admin">
<member name="kin"></member>
</group>
</basicRegistry>
<administrator-role>
<user>jayaramu</user>
<group>admin</group>
</administrator-role>
Then I ran the application server and try to validate database connection using below URL,
https://localhost:9443/ibm/api/validation/dataSource/database
It return CWWKO0801E: Unable to initialize SSL connection error in console. 403 error in browser.

Websphere Liberty How to get a MDB Listener working?

I'm trying to get an MDB Listener working in Websphere Liberty v16.0.0.4 but I don't get a message in my messages.log that the application that needs to use the MDB Listener has been bound to the activation spec.
I have the following information:
QueueManager: TEST
Hostname: localhost
Default ServerConnectionChannel: BAN.TEST.T1
Portnumber: 5704
Queue Connection Factory:
JndiName: jms/dbd_pega_CNVBANQCF
Type TCF/QCF/CF: QCF
ServerConnectionChannel: BAN.TEST.T1
Queue 1:
JndiName: jms/dbd_pega_CNVBAN_ReqQ
queueName: SRV00026.201206.BAN
Queue 2:
JndiName: jms/dbd_pega_CNVBAN_RplQ
queueName: BAN.RPL.BAN
Activation Specification:
JNDI Activation Specification: eis/dbd_pega_cnvbanQAS
Name Activation Specification: dbd_pega_cnvbanQAS
The JNDI name of the Destination Queue: jms/dbd_pega_CNVBAN_ReqQ
The MDB Listener is called CnvMQIbanServices.jar and is put in the ear file called prpc_j2ee14_ws.ear.
And this is my server.xml:
<xml version="1.0" encoding="UTF-8">
<server description="server">
<featureManager>
<feature>webProfile-7.0</feature>
<feature>localConnector-1.0</feature>
<feature>jdbc-4.1</feature>
<feature>ssl-1.0</feature>
<feature>servlet-3.1</feature>
<feature>ejb-3.2</feature>
<feature>ejbLite-3.2</feature>
<feature>ejbRemote-3.2</feature>
<feature>jndi-1.0</feature>
<feature>jms-2.0</feature>
<feature>jaxws-2.2</feature>
<feature>jaxb-2.2</feature>
<feature>restConnector-2.0</feature>
<feature>wmqJmsClient-2.0</feature>
<feature>jmsMdb-3.2</feature>
</featureManager>
<applicationManager autoExpand="true"/>
<jmsQueueConnectionFactory jndiName="jms/dbd_pega_CNVBANQCF" connectionManagerRef="ConMgr6">
<properties.wmqJms
transportType="CLIENT"
hostName="localhost"
port="5704"
channel="BAN.TEST.T1"
queueManager="TEST"/>
</jmsQueueConnectionFactory>
<connectionManager id="ConMgr6" maxPoolSize="2"/>
<jmsQueue id="jms/dbd_pega_CNVBAN_ReqQ" jndiName="jms/dbd_pega_CNVBAN_ReqQ">
<properties.wmqJms
baseQueueName="SRV00026.201206.BAN"
baseQueueManagerName="TEST"/>
</jmsQueue>
<jmsQueue id="jms/dbd_pega_CNVBAN_RplQ" jndiName="jms/dbd_pega_CNVBAN_RplQ">
<properties.wmqJms
baseQueueName="BAN.RPL.BAN"
baseQueueManagerName="TEST"/>
</jmsQueue>
<jmsActivationSpec id="prpc_j2ee14_ws/CnvMQIbanServices.jar/CnvMQIbanServices_J2CMessageEndpoint">
<properties.wmqJms
transportType="CLIENT"
destinationRef="jms/dbd_pega_CNVBAN_ReqQ"
destinationType="javax.jms.Queue"
hostName="localhost"
port="5704"
channel="BAN.TEST.T1"
queueManager="TEST"/>
</jmsActivationSpec>
</server>
If I import a MDB Listener into an application in Websphere Application Server I know that I need to bound the MDB Listener.jar file to the activation spec, so in this case in bound CnvMQIbanServices.jar to eis/dbd_pega_cnvbanQAS, I'm missing this but how do I need to put this in the server.xml and am I maybe missing something else?
In order to determine if you are using the correct value for the jmsActivationSpec id, look in the messages.log file after starting your server for a warning such as the following,
com.ibm.ws.ejbcontainer.mdb.internal.MDBRuntimeImpl W CNTR4015W: The message endpoint for the {MDB_NAME} message-driven bean cannot be activated because the {ACTIVATION_SPEC_NAME} activation specification is not available. The message endpoint will not receive messages until the activation specification becomes available.
Use the value that you see for {ACTIVATION_SPEC_NAME} as the jmsActivationSpec id value.

Spring jms to Websphere MQ connection error

AppConfig.xml settings:
<bean id="connectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName" value="abchost.com />
<property name="port" value="1414" />
<property name="queueManager" value="ABC_DEV" />
<property name="transportType" value="1" />
<jms:listener-container acknowledge="transacted">
<jms:listener destination="abc.queue.abc"
ref="someComplexServiceImpl"
method="doSomething" />
</jms:listener-container>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultDestinationName" value="abc.queue.abc"/>
</bean>
I get the following errors:
Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2035' ('MQRC_NOT_AUTHORIZED').
[9/26/16 13:13:35:758 CST] 000000aa SystemErr R at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:204)
[9/26/16 13:13:35:758 CST] 000000aa SystemErr R ... 98 more
Cause: JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'ABC_DEV' with connection mode 'Client' and host name 'abchost.com(1414)'.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2035' ('MQRC_NOT_AUTHORIZED')
What I like to find out is, is there problem in the codes or in some setting in Websphere MQ we need to configure? I wanna make sure this is not a fault in the program before I raise the problem to our Websphere MQ administrator (who by the way is just new to Websphere MQ)
We are using:
Websphere MQ version 9
Spring JMS Version 4.2.4.RELEASE
I used MQ Client to connect to MQ, and I was able to connect (via command line):
C:\Users\me>set MQSERVER=CH.ABC_DEV/TCP/abchost.com(1414)
C:\Users\me>set MQSAMP_USER_ID=someuser
C:\Users\me>c:\IBM\MQ\Tools\c\Samples\Bin\amqsbcgc.exe abc.queue.abc ABC_DEV
Enter password: p#ssword
--connected!
but why cant the same user work when connecting through WAS?
My application was also not able to connect to MQ although I provided the correct credentials. Enabling the authentication compatibility mode solved the issue.
See also: IBM MQ Connection authentication
If you are using mq-jms-spring-boot-starter you can add this in application.properties:
ibm.mq.userAuthenticationMQCP=false
Internally this will apply this to the connection factory:
cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, false);
As the message at the bottom clearly says, the connection attempt was rejected with reason code 2035, not authorized. Your MQ administrator must check the MQ error log on the queue manager side for the specific reason. There are multiple ways of setting up the connection authentication and authorization, you need to consult MQ documentation. Additionally, chances are after setting up the connection authorization the application will fail with 2035 when opening the queue(s), so keep reading.

Error connecting ActiveMQ

I am working on ActiveMQ JMS Spring application. I am using ActiveMQ instance which is present in Cloud server and i trying to read message from queue. In a configuration file i have configured broker URL as
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<!-- brokerURL, You may have different IP or port -->
<constructor-arg index="0" value="tcp://ip address:8161" />
</bean>
but when i try to connect it gives me error
Caused by: org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed: tcp://ip address:8161
at org.apache.activemq.transport.AbstractInactivityMonitor.doOnewaySend(AbstractInactivityMonitor.java:297)
at org.apache.activemq.transport.AbstractInactivityMonitor.oneway(AbstractInactivityMonitor.java:286)
at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:85)
at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:104)
at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81)
at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1409)
... 21 more
Can you please suggest me is am i missing something here?

Resources