• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

why did I get a ClassCastException?

 
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
 
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
 
Your mother is a hamster and your father smells of tiny ads!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic