gpt4 book ai didi

java - 无法将类型 [JmsManagedConnectionFactoryImpl] 的值转换为所需类型 [javax.jms.ConnectionFactory]

转载 作者:行者123 更新时间:2023-12-04 03:24:56 25 4
gpt4 key购买 nike

我已经通过 JNDI 设置了一个 JMSTemplate,如下所示:

<bean id="jmsTopicCancelacionTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultDestination" ref="cancelacionTopic" />
<property name="messageConverter" ref="oxmMessageConverter" />
<property name="destinationResolver" ref="jmsDestResolver" />
<property name="pubSubDomain" value="true" />
</bean>

<!-- look up the JMS ConnectionFactory in JNDI -->
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jms/ConnectionFactory</value>
</property>
</bean>

<bean id="requestQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jms/SchedulingRequestQueue</value>
</property>
</bean>

我的 web.xml:

<resource-ref>
<description>JMS Connection</description>
<res-ref-name>jms/ConnectionFactory</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

但是,当我尝试在我的 Websphere 中绑定(bind) JNDI 资源时,在启动我的应用程序时出现以下错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.jms.core.JmsTemplate com.plexus.xesac_il.server.service.decide.DecideServiceImpl.jmsTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [spring/xesac-il-appcontext-jms.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
... 116 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [spring/xesac-il-appcontext-jms.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:912)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:855)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
... 118 more
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl' to required type 'javax.jms.ConnectionFactory' for property 'connectionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:463)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:494)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:488)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1463)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 127 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [com.ibm.ws.sib.api.jms.impl.JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:267)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448)
... 133 more

据我了解,IBM 的 JmsManagedConnectionFactoryImpl 应该实现 JmsTemplate,否则我什至没有机会通过 WebSphere 绑定(bind)它,那么这里可能是什么问题?

最佳答案

JmsTemplate 是 Spring 框架中的一个类。所以类 JmsManagedConnectionFactoryImpl 与 JmsTemplate 无关(JmsTemplate 使用 ConnectionFactory,但不是相反的方式)。但是,我认为您的问题是,您正在将 JMS api 类打包到您的应用程序中。当您在 WebSphere 中部署应用程序时,WAS 在类路径中也有 API 类,并且您有冲突,因为在不同的类加载器中有两个 API jar。因此,只需从您的部署中排除 API jar,错误就会消失。

关于java - 无法将类型 [JmsManagedConnectionFactoryImpl] 的值转换为所需类型 [javax.jms.ConnectionFactory],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26650237/

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