tags:

views:

214

answers:

2

Whenever we run our Java client from within Eclipse to contact a server app using RMI, we get an exception: java.io.StreamCorruptedException: invalid type code: 01

This only happens from within Eclipse, nowhere else (IntelliJ, command line, etc.).

Does anyone know what's going on?

A: 

Could it be incompatibility between server and client code? What JVM did you use to compile each one?

duffymo
+2  A: 

You seem to have encountered this issue before ;) and it is seen with JBoss too.

It usually is a:

The ClassLoader that is in the context when the viewer is running is the org.apache.catalina.loader.WebappClassLoader.

So if I do the following:

ClassLoader savedClassLoader = Thread.currentThread.getContextClassLoader();
if (savedClassLoader.getClass().getName().equalsIgnoreCase("org.apache.catalina.loader.WebappClassLoader")){
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
}

and then set the saved loader back in the IConnection.Close(), it works

VonC