gpt4 book ai didi

java - 使用 IBM WAS ConnectionFactory 和 Spring 时出错

转载 作者:行者123 更新时间:2023-12-01 10:25:41 27 4
gpt4 key购买 nike

我正在尝试做一个简单的 WAS/Spring/JMS 应用程序。我正在使用 JNDI 从 WAS 获取 JMS 的连接工厂和目标。我正在尝试将这些对象与 Spring JMS 一起使用,但我似乎无法正确进行转换。我尝试将连接工厂转换为 javax.jms.ConnectionFactory 和 javax.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 +[]

最佳答案

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

关于java - 使用 IBM WAS ConnectionFactory 和 Spring 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35367314/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com