Announcement Announcement Module
No announcement yet.
ClassCastException for JMSTemplate Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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=""
    xmlns:xsi="" xmlns:aop=""

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

    <bean id="replyNotifier" class=""/>

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

    <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 id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="defaultDestination" ref="requestQueue"/>
    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

    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


    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,

  • #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.