Home » Java » Error creating bean with name 'inboundJms.container': Cannot resolve reference to bean 'connectionFactory'

Error creating bean with name 'inboundJms.container': Cannot resolve reference to bean 'connectionFactory'

Posted by: admin October 26, 2017 Leave a comment

Questions:

Am trying to listen weblogic queue with help of Spring integration.getting below Exception

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘inboundJms.container’: Cannot resolve reference to bean ‘connectionFactory’ while setting bean property ‘connectionFactory’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘connectionFactory’ available

Config.xml

<bean id="wljndiTemplate" class="org.springframework.jndi.JndiTemplate" lazy-init="true">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                <prop key="java.naming.provider.url">-------</prop>
                <prop key="java.naming.security.principal">-------</prop>
                <prop key="java.naming.security.credentials">-------</prop>
            </props>
        </property>
    </bean>

    <bean id="wlConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="wljndiTemplate" />
        <property name="jndiName" value="QueueConnFactory" />
    </bean>

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

    <bean id="inboundResponseQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="wljndiTemplate" />
        <property name="jndiName" value="OutboundQueue" />

InboundAdapter.xml

<jms:message-driven-channel-adapter id="inboundJms" destination="ContactOutboundQueue" channel="messageReceiver" />

    <!--<router id="msgRouter" auto-startup="true" input-channel="messageReceiver"  default-output-channel=""       ref="routeInfo"         method="getQueueMessage"/>-->

    <integration:service-activator id="msgRouter" input-channel="messageReceiver" ref="routeInfo" method="getQueueMessage"/>
Answers:

By default spring integration JMS components that require ConnectionFactory will be looking for a bean named ‘connectionFactory’ that points to ConnectionFactory implementation. You on the other hand have a ConnectionFactory bean under the name ‘wlConnectionFactory’. So either change its name to ‘connectionFactory’ or define a ‘connection-factory’ attribute on your ‘message-driven-channel-adapter’.

Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *