Skip to main content

ClassCastException

3 replies [Last post]
akhilkerkar
Offline
Joined: 2009-04-03
Points: 0

i am new to this forum.
i am developing an instant messanger using jxta
i am having the same problem as u are.

whn i try to find a local advertisement i am getting a ClasscastException:import net.jxta.impl.protocol.PipeAdv

The error comes on the following line
ModuleSpecAdvertisement mdsadv=(ModuleSpecAdvertisement)en.nextElement();
PipeAdvertisement pipeadv1 = mdsadv.getPipeAdvertisement();
............
where en is Enumeration en=null;
how to solve this exception
any urgent help would be greatly appreciated.
Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mick_000
Offline
Joined: 2009-01-22
Points: 0

Just try and retrieve the pipe adv alone, instead of retrieving module spec adv and then the pipe adv.

desaipremal
Offline
Joined: 2008-07-03
Points: 0

Well, the source of the problem is that you may have created an advertisement of a particular type (say Peer Advertisment) and of all the advertisments you are discovering in the event listener, the one discovered is of another type.

Try creating only one advertismeent say Pipe Advertisment and locating that same advertisment in the event listener. You will not see the classcast exception.

adamman71
Offline
Joined: 2007-01-31
Points: 0

Hi,

If I were you, I would try to use some debug statement like:

Advertisement Temp = mdsadv.getPipeAdvertisement();
System.out.println(Temp.getClass.getName());

just before the line causing the error.

This will give you info about the type of advertisement that is being return.

Then, you should be able to track the source of the problem further.

Cheers,

J.