Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to run server

 
shishir gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying out a simple rmi program from core java. before posting this mail i went through all the messages but couldn't solve the problem.

Interface:

import java.rmi.*;
public interface Product extends Remote {
String getDescription() throws RemoteException;
}
-------------------------
Implementation:

import java.rmi.*;
import java.rmi.server.*;
public class ProductImpl extends UnicastRemoteObject implements Product {
private String name;
public ProductImpl(String n) throws RemoteException{
name=n;
}
public String getDescription() throws RemoteException {
return "I am a " + name + ". Buy me!";
}
}
-------------------------------
Server:

import java.rmi.*;
import java.rmi.server.*;
public class ProductServer{
public static void main(String str[]){
try{
System.out.println("Constructing server implementation");
ProductImpl p1=new ProductImpl("BW Toaster");
ProductImpl p2=new ProductImpl("ZX Oven");
System.out.println("Binding server implementation to registry..");
Naming.rebind("toaster", p1);
Naming.rebind("oven", p2);
System.out.println("waiting for invocations from client..");
}
catch(Exception e) {
e.printStackTrace();
}
}
}
--------------------------
I am just trying server..... I have run rmic and i am running this application on a pc. Jus to test whether we succeeded in registering the remote objects I wrote a simple program.

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

public class Showbindings {
public static void main(String s[]) {
try{
String[] bindings=Naming.list("");
for(int i=0;i<bindings.length;i++)
System.out.println(bindings[i]);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
----------------------------
When i run the server, i get this error...

D:\java\rmi>java ProductServer
Constructing server implementation
Binding server implementation to registry..
java.rmi.ServerException: RemoteException occurred in server thread; nested exce
ption is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested excep
tion is:
java.lang.ClassNotFoundException: ProductImpl_Stub
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknow
n Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Unknown Source)
at ProductServer.main(ProductServer.java:12)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested ex
ception is:
java.lang.ClassNotFoundException: ProductImpl_Stub
... 6 more
Caused by: java.lang.ClassNotFoundException: ProductImpl_Stub
... 6 more
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the compiled stub class isn't on the rmiregistry's class path.
 
shishir gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you pl tell me how to set this classpath?
 
shishir gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have my jdk in c:\jdk
if i save my application in c:\jdk\bin folder then it works fine. i have to set classpath so that i can run my application from my folder for eg: c:\rmi\

my classpath settings are:
.;
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See HowToSetTheClasspath in the JavaRanch FAQ.

And (shudder) don't be putting class files into /jdk/bin !
 
shishir gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i do not save my files in \bin folder. i just tested it whether my program runs or not.
now i want to run my program from my folder. i am unable to do so. i tried to set the classpath...
set classpath=%classpath%;.;c:\jdk1.4\lib\classes.zip;.;

pl let me know where i am wrong.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic