使用 IBM WAS ConnectionFactory 和 Spring 时出错

Error using IBM WAS ConnectionFactory and Spring

我正在尝试做一个简单的 WAS/Spring/JMS 应用程序。我正在使用 JNDI 从 WAS 获取 JMS 的连接工厂和目的地。我正在尝试将这些对象与 Spring JMS 一起使用,但我似乎无法正确转换。我尝试将连接工厂转换为 javax.jms.ConnectionFactoryjavax.jms.QueueConnectionFactory。我应该使用某种类型的 Spring 连接工厂吗?任何帮助表示赞赏。是 8.5 和 Spring 4.2.4.RELEASE。

@Bean
public ConnectionFactory jndiConnectionFactory() throws NamingException {
    JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
    jndiObjectFactoryBean.setJndiName("jms/qcfBindingsXa");
    jndiObjectFactoryBean.setLookupOnStartup(true);
    jndiObjectFactoryBean.setCache(true);
    jndiObjectFactoryBean.setResourceRef(true);
    jndiObjectFactoryBean.setProxyInterface(javax.jms.ConnectionFactory.class);
    jndiObjectFactoryBean.afterPropertiesSet();
    return (ConnectionFactory) jndiObjectFactoryBean.getObject();
}


@Bean
public Destination destination() throws NamingException {
    JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
    jndiObjectFactoryBean.setJndiName("jms/app/insertQ");
    jndiObjectFactoryBean.setLookupOnStartup(true);
    jndiObjectFactoryBean.setCache(true);
    jndiObjectFactoryBean.setResourceRef(true);
    jndiObjectFactoryBean.setProxyInterface(javax.jms.Destination.class);
    jndiObjectFactoryBean.afterPropertiesSet();
    return (Destination) jndiObjectFactoryBean.getObject();
}

@Bean
public DefaultMessageListenerContainer messageListenerContainter() throws NamingException{
    DefaultMessageListenerContainer messageListenerContainter = new DefaultMessageListenerContainer();
    messageListenerContainter.setDestination(destination());
    messageListenerContainter.setConnectionFactory(jndiConnectionFactory());
    //messageListenerContainter.setMessageConverter(messageConverter());
    messageListenerContainter.setMessageListener(messageListener());
    messageListenerContainter.setSessionTransacted(true);
    messageListenerContainter.setDestinationResolver(destinationResolver());
    messageListenerContainter.afterPropertiesSet();
    return messageListenerContainter;
} 

错误:

2016-02-12 09:51:03,493 ERROR o.s.j.l.DefaultMessageListenerContainer - Could not refresh JMS Connection for destination 'queue:///APP.INPUT.OC' - retrying using FixedBackOff{interval=5000, currentAttempts=0, maxAttempts=unlimited}. Cause: AOP configuration seems to be invalid: tried calling method [public abstract javax.jms.Connection javax.jms.ConnectionFactory.createConnection() throws javax.jms.JMSException] on target 
[com.ibm.ejs.jms.JMSQueueConnectionFactoryHandle@18fbbd2_   
managed connection factory = com.ibm.ejs.jms.WMQJMSRAManagedConnectionFactory@c51fdbc4_ 
connection manager = com.ibm.ejs.j2c.ConnectionManager@199d9f8f_    
restricted methods enabled = false]; 
nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class +[]

想通了。伙计,我觉得自己很愚蠢吗? :/ 在服务器 class 路径和应用程序 class 路径上都有 javax.jms jar。 Spring 正在查看应用程序 jar,而 WAS 正在查看服务器 jar。我不控制或看不到 Server class 路径上的内容,所以我没有意识到重复。感谢所有至少读过这个问题的人。