Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > exception java.lang.ClassCircularityError

Thread Tools

exception java.lang.ClassCircularityError

arraylist arraylist is offline
Junior Member
Join Date: Mar 2011
Posts: 2
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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Throw Exception Vs Throw New Exception Kerri ASP .Net 2 10-27-2003 02:13 PM
Re: bizaar exception that isn't really an exception jeff ASP .Net 3 06-26-2003 01:02 PM
Re: bizaar exception that isn't really an exception jeff ASP .Net 0 06-24-2003 12:46 PM