Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why did I get a ClassCastException?

 
coco huang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Coco,
Try this
and see if that can solve your problem
Regards
Maulin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic