我正在尝试做一个简单的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 +[]
答案 0 :(得分:1)
想出来。男人我觉得自己很蠢。 :/服务器类路径上的javax.jms
jar以及应用程序类路径。 Spring正在查看应用程序jar,WAS正在查看服务器jar。我无法控制或可以看到Server类路径上的内容,因此我没有意识到重复。感谢所有至少阅读过这个问题的人。