Announcement Announcement Module
Collapse
No announcement yet.
ClassCastException for JMSTemplate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClassCastException for JMSTemplate

    Hi All,

    We are getting ClassCastException when casting the bean to JMSTemplate after reading it from context file.

    Below is the context file config
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

    <import resource="shared-context.xml"/>

    <bean id="replyNotifier" class="com.test.app.request.ReplyNotifier"/>

    <bean id="listener" class="org.springframework.jms.listener.adapter.Me ssageListenerAdapter">
    <property name="delegate" ref="replyNotifier"/>
    <property name="defaultListenerMethod" value="notify"/>
    </bean>

    <bean id="container" class="org.springframework.jms.listener.SimpleMess ageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="messageListener" ref="listener"/>
    <property name="destination" ref="replyQueue"/>
    </bean>


    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="defaultDestination" ref="requestQueue"/>
    </bean>
    Below is the exception:

    Caught java.lang.ClassCastException: org.springframework.jms.core.JmsTemplate cannot be cast to org.springframework.jms.core.JmsTemplate at line 41
    Message: org.springframework.jms.core.JmsTemplate cannot be cast to org.springframework.jms.core.JmsTemplatecom.test.a pp.request.MktgReportDetailsRequest.contents(MktgR eportDetailsRequest.java:41)



    Here our context.xml is a part of the war file and we are accessing the bean from outside the war as per our legacy framework. Just to give you a bit more info our package structure is like

    test.ear
    --test.jar
    --test.war

    A class in test.jar file is trying to get the bean from the context file which is under war file.


    Could any one please let me know, if there is a way to get it working?

    Best regards,
    Irfan

  • #2
    Don't include the spring jars in the war file only in the ear. Currently you have classloading issues with probably duplicated (or non existing) jars.

    Comment

    Working...
    X