# ClassNotFoundException am Client (RMI)



## comp89 (24. Apr 2008)

hey,
ich hab folgende Exception am Client:

```
java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
	java.lang.ClassNotFoundException: teachershelper.service.TeachersHelperServiceImpl
	at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
	at teachershelper.service.LoginWindow.onOK(LoginWindow.java:83)
	at teachershelper.service.LoginWindow.access$000(LoginWindow.java:31)
	at teachershelper.service.LoginWindow$1.actionPerformed(LoginWindow.java:49)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6038)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
	at java.awt.Component.processEvent(Component.java:5803)
	at java.awt.Container.processEvent(Container.java:2058)
	at java.awt.Component.dispatchEventImpl(Component.java:4410)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
	at java.awt.Container.dispatchEventImpl(Container.java:2102)
	at java.awt.Window.dispatchEventImpl(Window.java:2429)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:177)
	at java.awt.Dialog$1.run(Dialog.java:1039)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.lang.ClassNotFoundException: teachershelper.service.TeachersHelperServiceImpl
	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:247)
	at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:434)
	at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
	at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
	at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
	at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
	... 35 more
```
und das verwirrt mich sehr, da ich dachte das nur das RMI interface und nicht die implementierung selbst am client sein muss...

Client:

```
Registry reg = LocateRegistry.getRegistry(textField1.getText(), 1099);
//zeile83:                
TeachersHelperService service = (TeachersHelperService) reg.lookup("th");
                System.out.println(service.isAlive());
```

Server:

```
try {
                Registry rmireg;
                try {
                    rmireg = LocateRegistry.createRegistry(port);
                } catch (ExportException exe) {
                    rmireg = LocateRegistry.getRegistry(port);
                }
                if (obj == null) {
                    obj = new TeachersHelperServiceImpl();
                }
                rmireg.rebind("th", obj);
            } catch (RemoteException e1) {
                e1.printStackTrace();
                return;
            }
```


danke


----------



## tuxedo (24. Apr 2008)

Das Lookup beim Client läuft nicht über die Registry, sondern über "Naming". Daran wird's wohl liegen.

Woher hast du dir das denn zusammen kopiert?

- Alex


----------



## comp89 (24. Apr 2008)

das war nicht das Problem, aber danke.

das Problem war das der Server nicht von UnicastRemoteObject extended hat, die Fehlermeldung war in der hinsicht auch "sehr aussagekräftig", besser wär vl ein UnicastRemoteObject expected oda ähnliches...


----------

