Velocity Reviews

Velocity Reviews (
-   Software (
-   -   exception java.lang.ClassCircularityError (

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;

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 {
this.buf = buf;

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( :616)
at java.lang.ClassLoader.defineClass( :466)
at register.MyLoader.findClass(

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.


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.