• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I'm dying.Please help!!!

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have almost finish my network design and run the server side ok.But when I run the client it

java -Djava.rmi.server.codebase=file:/e:\project/ -cp e:\project suncertify.client.ClientConnection


give an exception:

ClientConnecion:java.lang.ClassCastException: suncertify.server.RemoteAccess_stub


What's wrong?
here's some of my code:


public class ClientConnection{
FactoryInterface factory;
RemoteAccess remote;

...
public void build(String host){
String rmiRegistryHost = host;
try{
factory=(FactoryInterface)Naming.lookup("//"+rmiRegistryHost+"/Factory"); //it's ok
remote= factory.getConnection();//throw exception here

...
}catch(Exception e){
System.out.println("ClientConnection:"+e);
}
}
}
public RemoteAccess getConnection throws RemoteException{
return new RecmoteAccess();
}


RemoteAccess and FactoryConnection are both extends and FactoryConnection will retrun a
unique RemoteAccess
UnicastRemoteObject
Please Help!!!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You know there are doctors out there that are experts in such cases. They try to treat people so that they don't die.
Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First off, you do not need to use codebase.
Codebase is only if you are doing dynamic downloading of Stubs. In order to do this you would have to assume that the assessor has a web server, which they probably do not have. And is also not in the requirements.
So try removing that and run it again and see if you have the same error.
Beside that you path is incorrect because of the slashes.
Also did you run rmic on your two remote classes.
With RMI what is actually returned is the Stub, therefore you need to cast to the DataAccess interface when you get the object in your client.
I'd check those areas too to make sure it is correct.
Mark
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have try what you told me ,but the exception still exits.

With RMI what is actually returned is the Stub, therefore you need to cast to the DataAccess interface when you get the object in your client.


Maybe the error came from what you said.
I've tried like:
DataInterface remote;
...
remote= (DataInterface)factory.getConnection();
But it still showed that exception.
Why?What's wrong?
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right ,after I change my code to

But it showed another exception:


java.rmi.ServerException:RemoteException occurred in server thread;nested exception is:
java.rmi.UnmarshaException: invalid method hash


What's wrong?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unmarshalling errors always have to do with RMISecurityManager. If you are using an RMISecurityManager, remove it, you don't really need it for this assignment.
I had had an RMISecurityManager on the client side only, but looking back I would have removed that one too.
Mark
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
I haven't used it at all.
But if I do not add codebase in server ,it will
show exception.
And after I add the codebase in server,it works ok.
What's wrong?
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you create the stubs using RMIC?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And have a copy of the stubs with the client stuff. You will need to include the stubs in the client's exectuable jar file.
Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic