You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by lernit2007 <er...@googlemail.com> on 2010/07/02 12:25:09 UTC

ClassCastException

Hello,

I have a following interface:

public interface Test extends Message {

public void testMessage();

public void getString();

}

If I get a Message I want to cast the Message in Test:

public void onMessage(Message message) {
   Test test = (Test) message;

}

But I get the following Exception:

java.lang.ClassCastException:
org.apache.activemq.command.ActiveMQTextMessage cannot be cast to Test.

Can you help me further please? I don't know, what the problem is.
-- 
View this message in context: http://old.nabble.com/ClassCastException-tp29054743p29054743.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: ClassCastException

Posted by Dejan Bosanac <de...@nighttale.net>.
Hi,

make sure you get javax.jms.Message in your onMessage() method, by
either importing it or using using it explicitly in the param
definition.

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net



On Fri, Jul 2, 2010 at 12:25 PM, lernit2007
<er...@googlemail.com> wrote:
>
> Hello,
>
> I have a following interface:
>
> public interface Test extends Message {
>
> public void testMessage();
>
> public void getString();
>
> }
>
> If I get a Message I want to cast the Message in Test:
>
> public void onMessage(Message message) {
>   Test test = (Test) message;
>
> }
>
> But I get the following Exception:
>
> java.lang.ClassCastException:
> org.apache.activemq.command.ActiveMQTextMessage cannot be cast to Test.
>
> Can you help me further please? I don't know, what the problem is.
> --
> View this message in context: http://old.nabble.com/ClassCastException-tp29054743p29054743.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
>