-
Bug
-
Resolution: Done
-
Major
-
2.1.2.Final
-
None
-
None
When a noncontextual object with injected values is serialized and later deserialized in a new container (ie. after restarting the container), the following NPE occurs:
java.lang.NullPointerException at org.jboss.weld.annotated.slim.backed.BackedAnnotatedField$SerializationProxy.getCandidates(BackedAnnotatedField.java:114) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedMember$BackedAnnotatedMemberSerializationProxy.resolve(BackedAnnotatedMember.java:57) at org.jboss.weld.annotated.slim.backed.BackedAnnotatedField$SerializationProxy.readResolve(BackedAnnotatedField.java:109) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1104) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1807) ....
The reason is that BackedAnnotatedMemberSerializationProxy.type is null, because the type is not yet known to the container. Serializing the object and then deserializing works as expected.