• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

distributed banking code , getting error : _stub class cannot be casted!!!

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Can anybody help me with this error.
I created a ditributed banking system, which is a code for atm machine. The client first connects to atm and atm connects with bank to do all operations like deposit, withdraw, balance and does security checking also.

I have rmiregistry ON. My bankserver and security service run on first cmd window and atmserver on second cmd window. I get the message that bankserver is bound to rmiregistry, security is also bound and atm server also bound to rmiregistry.

On third window, i started the client.

But when i run it, I get the following error:

java.lang.ClassCastException: cscie160.project.AccountImpl_Stub cannot be cast
o cscie160.project.AccountImpl
at cscie160.project.ATMImpl.getBalance(ATMImpl.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown So
rce)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sou
ce)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Sourc
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unkno
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at cscie160.project.ATMImpl_Stub.getBalance(Unknown Source)
at cscie160.project.Client.printBalances(Client.java:68)
at cscie160.project.Client.testATM(Client.java:53)
at cscie160.project.Client.main(Client.java:35)
Failed as expected: java.lang.ClassCastException: cscie160.project.AccountImpl_
tub cannot be cast to cscie160.project.AccountImpl
Failed as expected: java.lang.ClassCastException: cscie160.project.AccountImpl_
tub cannot be cast to cscie160.project.AccountImpl
Failed as expected: java.lang.ClassCastException: cscie160.project.AccountImpl_
tub cannot be cast to cscie160.project.AccountImpl
Unexpected error: java.lang.ClassCastException: cscie160.project.AccountImpl_St
b cannot be cast to cscie160.project.AccountImpl
Unexpected error: java.lang.ClassCastException: cscie160.project.AccountImpl_St
b cannot be cast to cscie160.project.AccountImpl
Unexpected error: java.lang.ClassCastException: cscie160.project.AccountImpl_St
b cannot be cast to cscie160.project.AccountImpl
Unexpected error: java.lang.ClassCastException: cscie160.project.AccountImpl_St
b cannot be cast to cscie160.project.AccountImpl
Failed as expected: java.lang.ClassCastException: cscie160.project.AccountImpl_
tub cannot be cast to cscie160.project.AccountImpl
Unexpected error: java.lang.ClassCastException: cscie160.project.AccountImpl_St
b cannot be cast to cscie160.project.AccountImpl
java.lang.ClassCastException: cscie160.project.AccountImpl_Stub cannot be cast
o cscie160.project.AccountImpl
at cscie160.project.ATMImpl.getBalance(ATMImpl.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown So
rce)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sou
ce)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Sourc
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unkno
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at cscie160.project.ATMImpl_Stub.getBalance(Unknown Source)
at cscie160.project.Client.printBalances(Client.java:68)
at cscie160.project.Client.testATM(Client.java:63)
at cscie160.project.Client.main(Client.java:35)

Can anybody please explain what is the cause of this error??? The code is too big, so i can post the portion of the relevant code if you want.But right now i am clueless what the problem is?

Thanks.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i've the same problem... how did you solved it??
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please check this thread
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic