I have implemented a simple RMI server and client. My RequestServer
object is available over RMI and provides method:
Customer getCustomer();
My server and the Customer class are defined in package serverengine.
My client is defined in package testclient which includes
serverengine.jar on its classpath.
I have run the server and client with all the required -D parameters
and everything works well.
I now want to refactor my server separating Customer out into a new
package (called ipcshare).
I have added ipcshare.jar to the server and client classpaths and they
both compile and rmic fine. But when I run the server it throws the
following error. (code snippet below)
java.rmi.ServerError: Error occurred in server thread; nested
exception is:
java.lang.NoClassDefFoundError: ipcshare/Customer
java.lang.NoClassDefFoundError: ipcshare/Customer
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:354)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at serverengine.ServerEngine.main(ServerEngine.java:23)
if (System.getSecurityManager() == null)
{
System.setSecurityManager(new RMISecurityManager());
}
try
{
RequestServerImplementation obj = new
RequestServerImplementation();
//This line works fine.
Customer c = new
Customer(1,"",null,null,null,"","","","",'c','c','c',"");
//This is where the error is thrown
Naming.rebind("//localhost/RequestServer", obj);
System.out.println("RequestServer bound in registry");
}
catch (Exception e)
{
System.out.println("RequestServer err: " + e.getMessage());
e.printStackTrace();
}
I needed to include the new jar file on the client run
parameter -Djava.rmi.server.codebase
oops
tvm anyway