Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   exception java.lang.ClassCircularityError (http://www.velocityreviews.com/forums/t745238-exception-java-lang-classcircularityerror.html)

arraylist 03-16-2011 08:09 PM

exception java.lang.ClassCircularityError
 
Hi. I have some problem. I send from server to client stream bytes by socket, which contains serialized object and his implementation class. This part of bytes, which contains implementation class I load it my own ClassLoader:


public class MyLoader extends ClassLoader {

byte[] buf;

public MyLoader(byte[] buf) {
this.buf = buf;
}

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
return defineClass(null, buf, 0, buf.length);
}


the rest part of bytes is readed by ObjectReader, which extends ObjectInputStream, because I need to apply my ClassLoader(MyLoader):


public class ObjectReader extends ObjectInputStream {

byte[] buf;

public ObjectReader(InputStream input, byte[] buf) throws IOException {
super(input);
this.buf = buf;
}

@Override
protected Class<?> resolveClass(ObjectStreamClass desc) throws ClassNotFoundException
{
String name = desc.getName();
try {
return Class.forName(name, false, new MyLoader(buf));
} catch (ClassNotFoundException ex) {
throw ex;
}
}
}


When I run this code I obtain exception:


java.lang.ClassCircularityError: blabla/Impl
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader. java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java :616)
at java.lang.ClassLoader.defineClass(ClassLoader.java :466)
at register.MyLoader.findClass(MyLoader.java:46)


Can you help me with this error. I used to NetBeansIDE. When I run this code in desktop project no exception thrown, but when I run it in web project this exception occur.

Thanks.


All times are GMT. The time now is 07:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.