Hallo Leute,
es ist mir bewusst, dass es über das Thema schon einige Beiträge gibt, trotzdessen war es mir leider nicht möglich mein Plug-In zum Laufen zu bewegen. Ich hoffe jemand kann mir einen Tipp geben.
Ich möchte einen RMI Server starten und das ganze als Eclipse Plug-In. Hier ist der (völlig abgespeckte) Code des Servers:
Das gibt mir die folgende Exception:
Ok. Kein SecurityManager. Also habe ich den SecurityManager hinzugefügt. Hier nochmal der Code:
Damit gibt es folgende Exception:
Das Policy-File liegt natürlich in d:\rmi.policy und gibt alle Permissions.
Ich hoffe jemand hat vielleicht einen guten Hinweis für mich.
Vielen Dank schonmal.
Edit: java5, Eclipse 3.2
Gruß,
Dominik
es ist mir bewusst, dass es über das Thema schon einige Beiträge gibt, trotzdessen war es mir leider nicht möglich mein Plug-In zum Laufen zu bewegen. Ich hoffe jemand kann mir einen Tipp geben.
Ich möchte einen RMI Server starten und das ganze als Eclipse Plug-In. Hier ist der (völlig abgespeckte) Code des Servers:
Code:
public class TestServerImpl extends UnicastRemoteObject implements TestServer {
private static final long serialVersionUID = -4030374539549388613L;
private TestServerImpl() throws RemoteException {
super();
}
public static void startTestServer() {
try {
LocateRegistry.createRegistry(1234);
} catch (RemoteException e2) {
e2.printStackTrace();
}
String serverName = null;
try {
serverName = "rmi://" + InetAddress.getLocalHost().getHostAddress() + ":1234/TestServer";
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
TestServerImpl server = null;
try {
server = new TestServerImpl();
} catch (Exception e) {
e.printStackTrace();
}
try {
Naming.rebind(serverName, server);
System.out.println (serverName + " bound to rmi registry, at port " + "1234" + ".");
} catch (RemoteException e) {
System.out.println ("Rebinding " + serverName + " failed.");
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
public void test() throws RemoteException {
}
Das gibt mir die folgende Exception:
Code:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: servertest.TestServer (no security manager: RMI class loader disabled)
...
Ok. Kein SecurityManager. Also habe ich den SecurityManager hinzugefügt. Hier nochmal der Code:
Code:
public class TestServerImpl extends UnicastRemoteObject implements TestServer {
private static final long serialVersionUID = -4030374539549388613L;
private TestServerImpl() throws RemoteException {
super();
}
public static void startTestServer() {
System.setProperty("java.security.policy", "d:/rmi.policy");
System.setProperty("java.rmi.server.ignoreStubClasses","true");
if(System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
LocateRegistry.createRegistry(1234);
} catch (RemoteException e2) {
e2.printStackTrace();
}
String serverName = null;
try {
serverName = "rmi://" + InetAddress.getLocalHost().getHostAddress() + ":1234/TestServer";
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
TestServerImpl server = null;
try {
server = new TestServerImpl();
} catch (Exception e) {
e.printStackTrace();
}
try {
Naming.rebind(serverName, server);
System.out.println (serverName + " bound to rmi registry, at port " + "1234" + ".");
} catch (RemoteException e) {
System.out.println ("Rebinding " + serverName + " failed.");
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
public void test() throws RemoteException {
}
}
Damit gibt es folgende Exception:
Code:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: servertest.TestServer
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:385)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:343)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at servertest.TestServerImpl.startTestServer(TestServerImpl.java:59)
at servertest.TestView$1.run(TestView.java:108)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:441)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: servertest.TestServer
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:375)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:240)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: servertest.TestServer
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:707)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:651)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:588)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1500)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1463)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
... 9 more
Das Policy-File liegt natürlich in d:\rmi.policy und gibt alle Permissions.
Ich hoffe jemand hat vielleicht einen guten Hinweis für mich.
Vielen Dank schonmal.
Edit: java5, Eclipse 3.2
Gruß,
Dominik
Zuletzt bearbeitet: