'com.ibm.mq.jmqi.JmqiException: The native JNI library 'mqjbnd64' was not found. For a client installation this is expected
I have created a Spring Boot application with JMS .I am using IBM MQ7 and trying to make a connection through client to access a queue with Spring JMS. Could anyone please help I am a newbie.
I am getting error in eclipse
Could not refresh JMS Connection for destination 'queue1' - retrying in 5000 ms. Cause: JMSFMQ6312: An exception occurred in the Java(tm) MQI.; nested exception is com.ibm.mq.jmqi.JmqiException: CC=2;RC=2495;AMQ8568: The native JNI library 'mqjbnd' was not found.
However I have tried to setup java.library.path in JVM arguments & Eclipse.ini in eclipse but still getting same error.
In Run Configuration: VM Arguments
-Djava.library.path="C:\Program Files (x86)\IBM\WebSphere MQ\java\lib64\mqjbnd.dll"
I have followed
https://stackoverflow.com/questions/3675883/accessing-mq-with-jms
https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q031570_.htm
I still getting same exception.
JMS Config:
@Configuration
@ComponentScan(basePackageClasses =
{
MessageListener.class
})
public class JmsConfig {
private static final Logger logger = LoggerFactory.getLogger(JmsConfig.class);
@Value("${ibm.mq.hostname}")
private String host;
@Value("${ibm.mq.port}")
private Integer port;
@Value("${ibm.mq.manager}")
private String queueManager;
@Value("${ibm.mq.channel}")
private String channel;
@Value("${ibm.mq.queue}")
private String queue;
@Value("${ibm.mq.timeout}")
private long timeout;
@Value("${ibm.mq.username}")
private String username;
@Value("${ibm.mq.password}")
private String password;
@Resource
private MessageListener listener;
@Bean
public MQTopicConnectionFactory mqTopicConnectionFactory() {
MQTopicConnectionFactory mqTopicConnectionFactory = new MQTopicConnectionFactory();
try {
mqTopicConnectionFactory.setHostName(host);
mqTopicConnectionFactory.setQueueManager(queueManager);
mqTopicConnectionFactory.setPort(port);
mqTopicConnectionFactory.setChannel(channel);
mqTopicConnectionFactory.setTransportType(CommonConstants.WMQ_CM_CLIENT);
mqTopicConnectionFactory.setCCSID(1208);
} catch (Exception e) {
logger.error("Error connecting to MQ: {}",e.getMessage());
}
return mqTopicConnectionFactory;
}
@Bean
UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter(MQQueueConnectionFactory mqQueueConnectionFactory) {
UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter = new UserCredentialsConnectionFactoryAdapter();
userCredentialsConnectionFactoryAdapter.setUsername(username);
userCredentialsConnectionFactoryAdapter.setPassword(password);
userCredentialsConnectionFactoryAdapter.setTargetConnectionFactory(mqQueueConnectionFactory);
return userCredentialsConnectionFactoryAdapter;
}
@Bean
@Primary
public MQQueueConnectionFactory mqQueueConnectionFactory() {
MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory();
try {
mqQueueConnectionFactory.setHostName(host);
mqQueueConnectionFactory.setQueueManager(queueManager);
mqQueueConnectionFactory.setPort(port);
mqQueueConnectionFactory.setChannel(channel);
mqQueueConnectionFactory.setTransportType(CommonConstants.WMQ_CM_CLIENT);
mqQueueConnectionFactory.setCCSID(1208);
} catch (Exception e) {
logger.error("Error connecting to MQ: {}",e.getMessage());
}
return mqQueueConnectionFactory;
}
@Bean
public DefaultMessageListenerContainer myAppListenerContainer()
{
DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
listenerContainer.setConnectionFactory(mqQueueConnectionFactory());
listenerContainer.setDestinationName(queue);
listenerContainer.setMessageListener(listener);
//listenerContainer.setMaxConcurrentConsumers(maxConsumers);
listenerContainer.setSessionTransacted(true);
return listenerContainer;
}
@Bean
@Primary
public CachingConnectionFactory cachingConnectionFactory(UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter) {
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
cachingConnectionFactory.setTargetConnectionFactory(userCredentialsConnectionFactoryAdapter);
cachingConnectionFactory.setSessionCacheSize(500);
cachingConnectionFactory.setReconnectOnException(true);
return cachingConnectionFactory;
}
@Bean
public JmsTemplate queueTemplate(CachingConnectionFactory mqQueueConnectionFactory) {
JmsTemplate jmsTemplate = new JmsTemplate(mqQueueConnectionFactory);
jmsTemplate.setReceiveTimeout(timeout);
return jmsTemplate;
}
}
Solution 1:[1]
The files are missing because they are not provided nor needed in a client install since you would not be connecting via bindings mode on a client only install. (source)
Somehow default (WMQ_CM_BINDINGS = 0) transport type for ConnectionFactory get used for ConnectionFactory which fails.
This doesn't work
mqQueueConnectionFactory.setTransportType(CommonConstants.WMQ_CM_CLIENT);
This works
mqQueueConnectionFactory.setIntProperty(CommonConstants.WMQ_CONNECTION_MODE, CommonConstants.WMQ_CM_CLIENT);
Other properties works as expected. Here is factory declaration
@Bean
@ConfigurationProperties(prefix = "ibm.mq")
public MQQueueConnectionFactory mqConnectionFactory() throws JMSException {
MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
factory.setIntProperty(WMQ_CONNECTION_MODE, WMQ_CM_CLIENT);
return factory;
}
with config
ibm.mq:
queueManager: <manager>
channel: <channel>
hostName: <host>
port: <port>
user: <user>
password: <pass>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

