Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI - NoClassFoundException

 
mj deacon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set up a basic server application. It contains three files namely
Arith.java (implements the Remote interface)
ArithImpl.java (implements Arith.java the server) and
ArithApp.java which is the client Application

All of these are in the same package. I have compiled all of these files and I execute the rmic ArithImpl command from within the ArithImpl.java file via Runtime.getRuntime.exec(...);
The stub and skeleton files are generated and still I get a class not found exception. I have checked the class path and these files are within the class path.
If anyone could help me I'd greatly appreciate it. Thanks


public class ArithImpl extends UnicastRemoteObject implements Arith{

public static final String HOST_NAME = "localhost";
public static final String ROOT = "C:/Work/Thesis~1/LearningRMI/";
public static final String CLASSPATH = ROOT;
public static final String POLICY_FILE = CLASSPATH+"policies/rmi.policy";
public static final String RMI_LOCATION = "C:/Progra~1/java/jdk1.5.0_03/bin/";

String objectName;

public ArithImpl(String s) throws RemoteException{
super();
objectName = s;
}

public int[] add(int[] a, int[] b) throws RemoteException {
int c[] = new int[10];
for (int i=0; i<10; i++)
c = a+b;
return c;
}

public static void main(String[] args) {
System.setProperty("java.security.policy",POLICY_FILE);
System.setProperty("java.class.path",CLASSPATH);


String rmic = RMI_LOCATION+"rmic -vcompat -classpath "+CLASSPATH+" "+ArithImpl.class.getName();
String registry = RMI_LOCATION+"\\rmiregistry";

try{
Runtime rt = Runtime.getRuntime();
rt.exec(rmic);
rt.exec(registry);
}
catch (IOException e){
e.printStackTrace();
}

RMISecurityManager sm = new RMISecurityManager();
System.setSecurityManager(sm);
try{
Naming.rebind("//"+HOST_NAME+"/ArithServer", obj);
System.out.println("ArithServer bound in registry");
}
catch (Exception e){
e.printStackTrace();
}
}
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set the classpath, where your java files reside, as your environment variable.

I have experienced that on windows this error persist even after setting the environment variable. So, copy those java files in your JAVA_HOME/bin/, where your rmic resides. It would surely work. After that try to rmic at the original position.
[ December 11, 2005: Message edited by: Adeel Ansari ]
 
Ilias
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you executing rmiregistry?? check which rmiregistry ur running on the title bar, because rmiregistry also exists in oracle. Always run rmiregistry from your current console e.g. c:\rmi> start rmiregistry
otherwise it gives class not found exception or nested exception in case of oracle registry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic