I'm stay in the same problem and did the same configuration, but not work. The connection factory yet is creating de IBM XA ConnectionFactory internally. I tried to set wrap-xa-resource to false, but the value dosen't redefined and I don't know why. So i did a connection wrapper on the connection factory getted of the jndi and it's work.
public class IBMMQConnectionFactoryWrapperWithoutXA implements ConnectionFactory {
final ConnectionFactory originalCF;
final ConnectionFactory mqCF;
final String username;
final String password;
public IBMMQConnectionFactoryWrapperWithoutXA(ConnectionFactory originalCF) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, NoSuchMethodException, InvocationTargetException {
this.originalCF = originalCF;
Field theMCFField = originalCF.getClass().getDeclaredField("theMCF");
theMCFField.setAccessible(true);
Object theMCFValue = theMCFField.get(originalCF);
Method getPasswordMethod = theMCFValue.getClass().getSuperclass().getSuperclass().getMethod("getPassword");
this.password = (String)getPasswordMethod.invoke(theMCFValue);
Field usernameField = theMCFValue.getClass().getSuperclass().getSuperclass().getDeclaredField("username");
usernameField.setAccessible(true);
this.username = (String)usernameField.get(theMCFValue);
Field theCFField = theMCFValue.getClass().getDeclaredField("theCF");
theCFField.setAccessible(true);
this.mqCF = (ConnectionFactory)theCFField.get(theMCFValue);
}
@Override
public Connection createConnection() throws JMSException {
return this.createConnection(username, password);
}
@Override
public Connection createConnection(String userName, String password) throws JMSException {
return this.mqCF.createConnection(userName, password);
}
@Override
public JMSContext createContext() {
return this.createContext(username, password);
}
@Override
public JMSContext createContext(String userName, String password) {
return this.mqCF.createContext(userName, password);
}
@Override
public JMSContext createContext(String userName, String password, int sessionMode) {
return this.mqCF.createContext(userName, password,sessionMode);
}
@Override
public JMSContext createContext(int sessionMode) {
return this.createContext(username, password, sessionMode);
}
}
To create a jmsConnectionFactoryBean:
@Bean
public ConnectionFactory jmsConnectionFactory() {
JndiObjectFactoryBean jmsCF = new JndiObjectFactoryBean();
jmsCF.setResourceRef(true);
ConnectionFactory cf = jmsCF.getJndiTemplate().lookup("jms/ibmCF");
return new IBMMQConnectionFactoryWrapperWithoutXA(cf);
}