Hi. I am working with Axis and I am running into a problem serializing
NonNegativeInteger. I looked at the list of open bugs, but I did not see this listed.
I ran a simple test against the latest CVS source and I got the following stack trace:
Exception in thread "main" java.lang.NullPointerException
at java.math.BigInteger.readObject(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at java.io.ObjectInputStream.invokeObjectReader(Unknown Source)
at java.io.ObjectInputStream.inputObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at MySerial2.main(MySerial2.java:35)
The java that I used to test this is this:
import java.net.URL;
import java.io.ObjectOutputStream;
import java.io.ByteArrayOutputStream;
import org.apache.axis.types.NonNegativeInteger;
import java.util.Calendar;
import java.io.ObjectInputStream;
import java.io.ByteArrayInputStream;
import java.io.*;
import java.math.*;
public class MySerial2 implements java.io.Serializable
{
public static void main(String args[]) throws Exception {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(new NonNegativeInteger("1"));
baos.close();
oos.close();
byte[] myBytes = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(myBytes);
ObjectInputStream ois = new ObjectInputStream(bais);
Object myObj = ois.readObject();
if (myObj instanceof NonNegativeInteger)
{
NonNegativeInteger nni = (NonNegativeInteger) myObj;
System.out.println("Successful");
}
}
catch (IOException e) {
e.printStackTrace();
}
}
}
If someone could please confirm that this is really a problem (and not already
documented somewhere), I would appreciate it. This would also be the case for the
other classes that extend BigInteger (NonPositiveInteger, PositiveInteger,
NegativeInteger). Thanks.
Michael Baker