简体   繁体   中英

NoClassDefFoundException when receiving object with readObject()

Here's my setup:

My server waits for IPlugin-Objects with an ObjectInputStream . The incoming IPlugin-Ob ject is of an unknown class, so first, the class-file is transmitted and loaded by the classloader of the OIS. Then, the IPlugin itself is sent by the client. The cast of the IPlugin seems not to be a problem (when using my own classloader in the OIS). But the IPlugin uses jama and now I got an NoClassDefFoundException when I receive the object. The weird thing for me is, that in the servers classpath the Jama-library is contained. I also tried, to write a dummy-line, so the library will really be imported (and not ignored by the compiler).

Can anybody help me on that? It really bugs me...

Okay, I've got it:

The problem was, that my personal URIClassLoader got every URI possible, except the current classloader. Now the constructor looks like the following:

URLClassLoader loader = new URLClassLoader(new URL[]{pluginFolder.toURI().toURL()},
this.getClass().getClassLoader());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM