总而言之,我有一个Swing应用程序,可通过RMI与服务器协作。可以正常运行。
我正在将该应用程序移动为Rhapsody插件。一切正常,直到我绑定到服务器内的远程obj。然后引发ClassnotfoundException。
我已经确保使用-Djava.rmi.server.useCodebaseonly=false
使用同一开关调用服务器,包括开关-Djava.rmi.server.codebase="file:/C:/Users/esb/eclipse-workspace/modelHarvester/bin/entryPoint/"
,并通过rhapsody.ini文件中的JVM部分调用Rhapsody插件(客户端)。
客户端中令人讨厌的代码是“ lookup”语句
public class HarvesterConnection {
private static Registry myRegistry = null;
private static HarvesterInterface myHarvester = null;
private static boolean needsConnecting = true;
public static HarvesterInterface connect()
{
if (needsConnecting)
{
try
{
myRegistry = LocateRegistry.getRegistry(null);
myHarvester = (HarvesterInterface) myRegistry.lookup("Harvester");
needsConnecting = false;
}
catch (RemoteException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (NotBoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return myHarvester;
}
}
为了完整起见,这是服务器端的一部分
public static void main(String[] args)
{
final Options toolOptions = new Options();
try
{
ToolTrace.traceTheTool(TracePhase.Initialising,TraceGranularity.ALWAYS,"Harvester Server initialising");
buildCommandLineOptionsProcessor(toolOptions);
if (detectCryForHelp(args))
{
/*
* Just display the help.
* Do NO processing even if
* source model argument is
* present.
*/
displayToolUsageHelp(toolOptions);
}
else
{
try
{
LocateRegistry.createRegistry(1099);
ToolTrace.traceTheTool(TraceGranularity.INFO,"java RMI registry created");
}
catch (RemoteException e1)
{
// error means that registry already exists
ToolTrace.traceTheTool(TraceGranularity.INFO,"java RMI already exists");
}
try
{
/*
* Main processing thread.
*/
ToolTrace.traceTheTool(TraceGranularity.ALWAYS,"Processing Started");
readComandLineArguments(args,toolOptions);
/*
* Instantiate the Server
*/
HarvesterInterface localServer = new HarvesterServer();
myServer = (HarvesterServer)localServer;
HarvesterInterface stubObject = (HarvesterInterface) UnicastRemoteObject.exportObject(localServer,0);
/*
* Bind the local Server to the name "Harvester" in the registry
*/
Registry localRegistry = LocateRegistry.getRegistry(1099);
localRegistry.rebind("Harvester",stubObject);
ToolTrace.traceTheTool(TraceGranularity.ALWAYS,"Harvester bound in registry");
}
catch (ToolUsageException e )
{
ToolTrace.traceTheTool(e);
exitCode = 1;
}
catch (RemoteException e)
{
ToolTrace.traceTheTool(TraceGranularity.ERROR,"Registry FAILURE","Cannot locate registry");
e.printStackTrace();
exitCode = 1;
}
catch (Exception e) {
ToolTrace.traceTheTool(TraceGranularity.ERROR,"Tool FAILURE","Other unhandled exception");
e.printStackTrace();
exitCode = 1;
}
}
}
catch (ToolUsageException e)
{
ToolTrace.traceTheTool(e);
exitCode = 1;
}
}
关于此问题的任何明智的想法??预先感谢