473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can't Cast To Interface?

I'm trying to build a custom renderer for a Sonic multipartmessage...

public String render(javax.jms.Message msg)
{
stuff
}

msg.getClass() returns "class progress.message.jimpl.xmessage.MultipartMessage"

but if I try casting it to progress.message.jimpl.xmessage.MultipartMessage it crashes, telling me "java.lang.ClassCastException: progress.message.jimpl.xmessage.MultipartMessage cannot be cast to progress.message.jimpl.xmessage.MultipartMessage".

Likewise...

msg.getClass().getInterfaces()[0] returns interface progress.message.jclient.MultipartMessage

But if I try casted it to progress.message.jclient.MultipartMessage I get "ERROR: progress.message.jimpl.xmessage.MultipartMessage cannot be cast to progress.message.jclient.MultipartMessage
>java.lang.ClassCastException: progress.message.jimpl.xmessage.MultipartMessage cannot be cast to progress.message.jclient.MultipartMessage
"

How can it simultaneously be, and not be, a given class? What am I overlooking?

Thanks.

Ps-> Here is the declaration of MultipartMessage...

public class progress.message.jimpl.xmessage.MultipartMessage extends progress.message.jimpl.Message implements progress.message.jclient.MultipartMessage
Sep 5 '08 #1
3 9606
JosAH
11,448 Expert 8TB
If you get an "cannot cast X to X" message you've got a classpath problem, i.e.
during runtime you're using an X different from you were using during compile time.

kind regards,

Jos
Sep 5 '08 #2
Awesome, thanks. Turns out i was loading the one jar twice. I've been struggling with that for two weeks. Big thanks, JosAH.
Sep 5 '08 #3
JosAH
11,448 Expert 8TB
Awesome, thanks. Turns out i was loading the one jar twice. I've been struggling with that for two weeks. Big thanks, JosAH.
You're welcome of course but a class is only loaded twice or more when it is
loaded by different classloaders. (or by a very forgetfull classloader) Is your
problem solved now?

kind regards,

Jos
Sep 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Markus | last post by:
This is my TABLE: CREATE TABLE test( data BLOB ) This is my INSERT: INSERT INTO test(data) VALUES (CAST('I am a test' AS BLOB)) But how can I SELECT the data as VARCHAR, so that I can see...
1
by: Derrick | last post by:
Hopefully someone can explain to me why this doesn't work: - I have an interface ("IFoo"), the source of which lives in "Assembly A" - A class ("Foo") which implements this interface lives in...
0
by: Daylor | last post by:
how can i cast remote object ? if i have remote object to type Cbase that holds CDerived object. how can i cast in the client from CBase To CDerived ?
12
by: Abhishek | last post by:
now suppose I have declared an integer value inside a function as int x; now if the return type of the function is of type (void *) then can I write return((void *)x) in side the function? I...
5
by: Jimp | last post by:
Why can't I cast List<MyObject> to ICollection<IMyObject>. MyObject implements IMyObject, and of course, List implements ICollection. Thanks
6
by: Ron M. Newman | last post by:
Hi, Under what circumstances can I ever get an exception about not being able to cast type "ABC" to type "ABC" if there's only one ABC class in the system and it's loaded from a dynamic...
9
by: Leon_Amirreza | last post by:
How Can I cast a uint type to a byte? Does the following code do this? uint a = 5; byte b = new byte; b = (byte)a;
4
by: Gotch | last post by:
Hi, I'm getting a very strange behaviour while running a project I've done.... Let's expose it: I've two projects. Both of them use a Form to do some Gui stuff. Other threads pack up messages...
4
by: yumbelie | last post by:
Hi, I've got a function that returns an object of type: system.web.ui.control - Now I've created a very simple class, derived from system.web.ui.control: Public Class MyTest ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.