[jacorb-developer] CORBA Any Serialization and Deserialization
Chun Tat David Chu
beyonddc.storage at gmail.com
Mon Mar 24 18:52:09 CET 2014
Hi All,
I am currently using JacORB 3.2. I have a requirement where I need to
serialize a CORBA Any, write it to a file and then read it back as a CORBA
Any.
For the CORBA Any Serialization, I wrote the following code:
org.omg.CORBA.portable.InputStream in = anyData.create_input_stream();
byte[] byteArray = IOUtils.toByteArray(in);
FileUtils.writeByteArrayToFile(new File(msgDestination), byteArray);
When converting the byte array back to CORBA Any, I did the following:
byte[] messageByte = FileUtils.readFileToByteArray(message);
org.jacorb.orb.CDRInputStream inputStream =
new org.jacorb.orb.CDRInputStream(this.orb, messageByte);
Any anyData = inputStream.read_any();
However I encountered an ArrayIndexOutOfBoundsException that is thrown by
the read_any() method.
java.lang.ArrayIndexOutOfBoundsException: 4
at
org.jacorb.orb.CDRInputStream.read_octet(CDRInputStream.java:1105)
at org.jacorb.orb.Any.read_value(Any.java:1202)
at org.jacorb.orb.CDRInputStream.read_any(CDRInputStream.java:667)
That led me think that I probably did something wrong in the code. Can
anyone lead me to the right path on serializing and deserializing CORBA Any?
Thanks,
David
More information about the jacorb-developer
mailing list