aspose file tools*
The moose likes Applets and the fly likes why did I get a ClassCastException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "why did I get a ClassCastException?" Watch "why did I get a ClassCastException?" New topic
Author

why did I get a ClassCastException?

coco huang
Greenhorn

Joined: Sep 14, 2003
Posts: 4
I use a applet to communicate rmi,but I got a ClassCastException.
java.lang.ClassCastException: sun.rmi.registry.RegistryImpl_Stub
at ProductApplet.init(ProductApplet.java:18)
at sun.applet.AppletPanel.run(AppletPanel.java:344)
at java.lang.Thread.run(Thread.java:484)
here are my code:
public class ProductApplet extends Applet
{
public void init()
{
//initUI();
String myUrl = getCodeBase().getHost();
System.out.println(getCodeBase());
System.out.println("url = " + myUrl);
myUrl = "rmi://" + myUrl;
try
{
c1 = (Product)Naming.lookup(myUrl + "toaster");
System.out.println(c1);
//System.out.println(c1.getDescription());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
I have start rmiregistry and run my server and web server,and I put applet.class file and stub file in one folder(webapps/download).
huangwei@edu.21cn.com


coco
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi Coco,
Try this
and see if that can solve your problem
Regards
Maulin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why did I get a ClassCastException?