【问题标题】:Error using IBM WAS ConnectionFactory and Spring使用 IBM WAS ConnectionFactory 和 Spring 时出错
【发布时间】:2016-02-13 01:36:48
【问题描述】:

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

【问题讨论】:

    标签: java spring jms spring-jms ibm-was


    【解决方案1】:

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

    【讨论】:

    • 嗨...你能告诉我你是如何解决这个问题的吗?
    猜你喜欢
    • 1970-01-01
    • 2015-02-23
    • 2021-03-26
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-19
    • 2020-01-03
    相关资源
    最近更新 更多