简体   繁体   English

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

[英]Cannot convert value of type [JmsManagedConnectionFactoryImpl] to required type [javax.jms.ConnectionFactory]

I have set up a JMSTemplate via JNDI like this: 我已经通过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>

My web.xml: 我的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>

However, when I try to bind the JNDI resource in my Websphere, I get the following error when starting up my application: 但是,当我尝试在Websphere中绑定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

It is my understanding that IBM's JmsManagedConnectionFactoryImpl should be implementing JmsTemplate or otherwise I wouldn't even have the chance to bind it through WebSphere, so what could be the problem here? 据我了解,IBM的JmsManagedConnectionFactoryImpl应该实现JmsTemplate,否则我什至没有机会通过WebSphere绑定它,那么这可能是什么问题呢?

JmsTemplate is a class from the Spring framework. JmsTemplate是Spring框架中的一个类。 So the class JmsManagedConnectionFactoryImpl has nothing to do with the JmsTemplate (the JmsTemplate uses the ConnectionFactory, but not the reversed way). 因此,类JmsManagedConnectionFactoryImpl与JmsTemplate无关(JmsTemplate使用ConnectionFactory,但不是相反的方式)。 However, i think your problem is, that you are packaging the JMS api classes in your application. 但是,我认为您的问题是,您正在将JMS api类打包在您的应用程序中。 When you deploy the application in WebSphere, WAS has also the API classes in the classpath, and you have a conflict, because there are two API jars in different classloaders. 当您在WebSphere中部署应用程序时,WAS在类路径中也有API类,并且您会发生冲突,因为在不同的类加载器中有两个API jar。 So just exclude the API jars from your deployment, and the error should be gone. 因此,只需从您的部署中排除API jar,错误就应该消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 配置(基于注释):NoUniqueBeanDefinitionException:没有可用的“javax.jms.ConnectionFactory”类型的合格 bean: - Spring configuration (annotation based): NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.jms.ConnectionFactory' available: ClassCastException:将IBM MQ配置为Flume JMS源时,无法将javax.nam.Conction转换为javax.jms.ConnectionFactory - ClassCastException: javax.naming.Reference cannot be cast to javax.jms.ConnectionFactory when configuring IBM MQ as Flume JMS Source javax.jms.ConnectionFactory仅在登录到根目录时才连接 - javax.jms.ConnectionFactory only connecting when logged in a root ActiveMQ Artemis:javax.jms.ConnectionFactory 在故障转移的情况下不接收集群拓扑 - ActiveMQ Artemis: javax.jms.ConnectionFactory does not receive cluster topology in case of failover IllegalStateException:无法将type的值转换为必需的类型 - IllegalStateException: Cannot convert value of type to required type 无法将“java.lang.String”类型的值转换为所需类型 - Cannot convert value of type 'java.lang.String' to required type 无法将值类型“Configuration”转换为属性 freeMarkerConfigurationFactoryBean 所需的类型 FreeMarkerConfigurationFactoryBean - Cannot convert value type 'Configuration' to required type FreeMarkerConfigurationFactoryBean for property freeMarkerConfigurationFactoryBean 在JMS上找不到具有JNDI的ConnectionFactory - Cannot find ConnectionFactory with JNDI on JMS 无法将类型“ java.util.ArrayList”的属性值转换为所需的类型“ javax.xml.ws.handler.HandlerResolver” - Failed to convert property value of type 'java.util.ArrayList' to required type 'javax.xml.ws.handler.HandlerResolver' Spring Security:无法将类型[…]的值转换为所需的类型[org.springframework.security.web.authentication.logout.LogoutSuccessHandler] - Spring Security: Cannot convert value of type [ …] to required type [org.springframework.security.web.authentication.logout.LogoutSuccessHandler]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM