Network Serialization

How do you use the Serializer to write and read from ByteBuffer?

I tried and I keep getting a java.lang.UnsupportedOperationException



ByteBuffer buffer = BufferUtils.createByteBuffer(1024);

Serializer.writeClassAndObject(buffer, o); // o is a object

return buffer.array();[/java]

I’d probably have to see the stack trace for the exception and the rest of its message (if there was one).

Note: if you don’t register your classes ahead of time then you likely won’t be able to read the data again… since reading will definitely require registration and it has to be done in exactly the same order. (Unless you are giving everything specific IDs… then the order doesn’t matter as much but you’ll still need to register ahead of reading.)

Here is the stacktrace.



at java.nio.ByteBuffer.array(

at shared.util.Cryption.encryptObject(


at server.MainApplication.main(

Looks to me like the bytebuffer.array is the problem. The object is registered and the underlying types in the class are registered as well.

What’s this doing:


What is that code trying to do and to which ByteBuffer?

By the way… 99.999% sure this is creating a direct memory buffer:

ByteBuffer buffer = BufferUtils.createByteBuffer(1024);

…you probably don’t want that as the memory is native and therefore access from Java is slightly slower and you can’t do things like array().