简体   繁体   中英

Weblogic and Spring JMS configuration throws java.lang.IllegalStateException

Converting EJB MDB application to Spring base JMS service.

JMS Queue configuration is in Weblogic server.

Have following in configuration in applicationContext XML file.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">


    <bean id="vTMessageQueueListener" class="com.collection.mom.sink.EventMessageBean" />

    <bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>/jms/FilingTopicConnFact</value>
        </property>
    </bean>

    <bean id="jmsDestinationResolver"
        class="org.springframework.jms.support.destination.JndiDestinationResolver">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="cache">
            <value>true</value>
        </property>
    </bean>

    <bean id="QueueTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
            <ref bean="queueConnectionFactory" />
        </property>
        <property name="destinationResolver">
            <ref bean="jmsDestinationResolver" />
        </property>
    </bean>

    <bean id="SMMessageQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
        <!--<property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>-->
        <property name="jndiName">
            <value>com/vx/jms/vTMessageQueue</value>
        </property>
    </bean>


    <bean id="V3JMSlistener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="concurrentConsumers" value="5" />
        <property name="connectionFactory" ref="queueConnectionFactory" />
        <property name="destinationName" ref="SMMessageQueue"/>
        <property name="messageListener" ref="vTMessageQueueListener" />
    </bean>

</beans>

.

<HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'V3JMSlistener' defined in class path resource [SpringJMSContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'V3JMSlistener' defined in class path resource [SpringJMSContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:584)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found
        at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:590)
        at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:604)
        at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:219)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1697)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1653)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalStateException: Cannot convert value of type 'weblogic.jms.common.DestinationImpl' to required type 'java.lang.String' for property 'destinationName': no matching editors or conversion strategy found
        at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:299)
        at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:585)
        at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:604)
        at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:219)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1697)
        Truncated. see log file for complete stacktrace

Any help will be appreciated!!!

Use

<property name="destination" ref="SMMessageQueue"/>

instead of destinationName .

Spring can resolve a destination from its name but since you have the destination, you should inject that directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM