Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法将[JmsManagedConnectionFactoryImpl]类型的值转换为所需的[javax.jms.ConnectionFactory]类型_Java_Spring_Jms_Websphere_Jndi - Fatal编程技术网

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

无法将[JmsManagedConnectionFactoryImpl]类型的值转换为所需的[javax.jms.ConnectionFactory]类型,java,spring,jms,websphere,jndi,Java,Spring,Jms,Websphere,Jndi,我通过JNDI设置了一个JMSTemplate,如下所示: <bean id="jmsTopicCancelacionTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <property name="defaultDestination" re

我通过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>

据我所知,IBM的JmsManagedConnectionFactoryImpl应该实现JmsTemplate,否则我甚至没有机会通过WebSphere绑定它,那么这里会有什么问题呢?

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

我知道它们是不同的;我的意思是,JmsTemplate需要一个javax.jms.ConnectionFactory,这就是我提供给它的。当你谈论api时,你的意思是我应该排除包含javax.jms.ConnectionFactory的JAR,让WAS使用他的?难道不应该通过将我的项目配置为父类(我已经有了)来避免这种情况吗?不,因为然后WebSphere使用他的类来初始化JMS连接(因为您在WebSphere中配置了它),然后Spring尝试将WebSphere中的连接对象与应用程序特定的类一起使用,这是相同的代码,但是不同类加载器的不同类对象(您刚刚加入了类加载器地狱)。您好,感谢这个线程,它非常有用。但是,在从WEB-INF/lib中删除所有ActiveMQ依赖项并将WS-class loader设置为父类last和single class loader之后,我仍然存在这个问题。我是否应该从部署中排除任何其他API?谢谢。如果还有一个JAR,里面有ConnectionFactory类,您能在IDE中进行搜索吗?Eclipse和IntelliJ应该显示,如果您打开某个JAR,它将保存一个特定的类。
<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>
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