• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

RMI stub is generating errors  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my first program on RMI. But some runtime errors are generated when i use rmic tool to generate stub

"RemoteAdd.java"

import java.rmi.*;

public interface RemoteAdd extends Remote{
public double add(double n1, double n2) throws RemoteException;
}




"RemoteAddServer.java"

import java.rmi.*;
import java.rmi.server.*;

public class RemoteAddServer extends UnicastRemoteObject implements RemoteAdd{

public double add(double n1, double n2){
return (n1+n2);
}

public RemoteAddServer() throws RemoteException{}

public static void main(String[] a){
try{
RemoteAddServer service = new RemoteAddServer();
Naming.rebind("AddRemoteService", service);
}catch(Exception ex){ ex.printStackTrace();}
}

}


"RemoteAddClient.java"

import java.rmi.*;

public class RemoteAddServer extends UnicastRemoteObject implements RemoteAdd{

public double add(double n1, double n2){
return (n1+n2);
}

public RemoteAddServer() throws RemoteException{}

public static void main(String[] a){
try{
RemoteAddServer service = new RemoteAddServer();
Naming.rebind("AddRemoteService", service);
}catch(Exception ex){ ex.printStackTrace();}
}

}

When i type "d:\Program Files\Core> rmic RemoteAddServer", i get the following errors

D:\Program Files\Core\RemoteAddServer_Stub.java:33: Incompatible type for declar
ation. Explicit cast needed to convert java.lang.Object to Object.
Object $result = ref.invoke(this, $method_add_0, new java.lang.Objec
t[] {new java.lang.Double($param_double_1), new java.lang.Double($param_double_2
)}, 864055858262779977L);
^
D:\Program Files\Core\RemoteAddServer_Stub.java:34: Invalid cast from Object to
java.lang.Double.
return ((java.lang.Double) $result).doubleValue();
^
2 errors

My .class files have been generated successfully. My all java files reside in "d:\Program Files\Core" directory.
 
Marshal
Posts: 61690
192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please go back and edit your post to add code tags, otherwise your post is illegible.
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tripti Ag wrote:This is my first program on RMI. But some runtime errors are generated when i use rmic tool to generate stub

"RemoteAdd.java"






"RemoteAddServer.java"



"RemoteAddClient.java"



When i type "d:\Program Files\Core> rmic RemoteAddServer", i get the following errors

D:\Program Files\Core\RemoteAddServer_Stub.java:33: Incompatible type for declar
ation. Explicit cast needed to convert java.lang.Object to Object.
Object $result = ref.invoke(this, $method_add_0, new java.lang.Objec
t[] {new java.lang.Double($param_double_1), new java.lang.Double($param_double_2
)}, 864055858262779977L);
^
D:\Program Files\Core\RemoteAddServer_Stub.java:34: Invalid cast from Object to
java.lang.Double.
return ((java.lang.Double) $result).doubleValue();
^
2 errors

My .class files have been generated successfully. My all java files reside in "d:\Program Files\Core" directory.

 
Campbell Ritchie
Marshal
Posts: 61690
192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for editing the code.

Do you have a class called Object anywhere?
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, i have only these three java files in my directory. I tried another program where remote method does not return anything. It ran successfully. So, my problem occurs only when remote method returns something.
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am unable to solve this problem. Can anyone help me? Thanks in advance.
 
Sheriff
Posts: 21463
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tripti Ag wrote:No, i have only these three java files in my directory.


And what about class files? Is there an old Object.class around?
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, i have Object.class in my directory
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is Object.class is the reason for above problem. What should i do next to solve this problem? Thanks in advance.
 
Rob Spoor
Sheriff
Posts: 21463
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Delete it. This class file makes the compiler use your own custom Object class instead of java.lang.Object. Since you have no source of it it's probably a remainder of a class you wrote before but then removed.
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob, problem is resolved.
 
Rob Spoor
Sheriff
Posts: 21463
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

Although quite late I am moving this (solved) thread to our Distributed Java forum. That's where we handle RMI, not here. I should have done that before.
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!