Question

I have a javaagent attached to a remote process using agentmain which sends serialized java objects via socket to a client application.

There appears to be a bug in the formatting of the stream which I am not sure if it is an error in my writeExternal implementation or if it is something to do with the java versions. I am experimenting with different combinations of java 1.6 32 / 64 bits.

Basically the object stream is throwing a class not found exception, but the package name printed is something like org.mycode.b.e.b., the b.e.b part is nothing to do with any packages I own and I have searched all over and there is nothing in my code or libraries with that string... b.e.b.

So I am suspicious it is an encoding issue caused by either a encoding format discrepancy or a 32/64 bit word length issue, but I am not that experienced in these areas.

I am quite used to opening up the debugger to track down code issues, but less experienced diagnosing problems of this nature, with serialization and byte formats so I am asking to see what are the recommended approaches to debugging?

I have control/compilation/source of the client which uses code like:

objectInput = new ObjectInput(inputStream);
Object object = objectInput.readObject(); 

which currently throws class not found for the org.mycode.b.e.b.

I was thinking about re-writing it to store the serialized stream to a file and taking a look ( not sure what format the file will actually be in in regard to reading it), is that the right angle?

Was it helpful?

Solution

The format for ObjectOutputStream is unchanged whether you use 32-bit or 64-bit or a big endian or little endian machine. Where there have been problems in the past has been between Java 1.3 and Java 1.4 using slightly different formats. Also Eclipse and Sun used different algos to generate serialVersionUID so you can run into problems if you didn't hard code it.

However if you have packages like b.e.b you most likely have obfuscated your code which is designed to make it difficult to work with. I suggest you only debug/monitor your un-obfuscated code.

OTHER TIPS

I addition to commend of @Peter Lawrey.

I think that to simplify your debugging you should work with non-obfuscated code. This will give you at least the tip where the problem is.

Moreover probably the fact of partial obfuscation is the root cause of your problem. Think: you object is serialized on client side that is not obfuscated. Let's say your class named MyFirstClass depends on MySecondClass and is serialized accordingly. But on server side the MySecondClass is named q. Why q? This is up to obfuscator. Moreover this name may be different for each build. So, the server side cannot find the class MySecondClass.

Other possible problem is serialiVersionUID. Probably you have to define this variable for all relevant classes and handle its value.

But first just avoid obfuscation and try again. I believe everything will work. Good luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top