jaxb-ri icon indicating copy to clipboard operation
jaxb-ri copied to clipboard

2.3.8 @XmlValue with @XmlJavaTypeAdapter causes NullPointerException

Open lulnope opened this issue 1 year ago • 3 comments

Hi, i've stumbled into issues with marshalling/unmarshalling java types based on xsd complex type derived from a simple type by addition of an attribute. The issue occurs only if i put @XmlJavaTypeAdapter on value field. Following is a link to my repository where i've uploaded 2 test cases for the issue in a form of maven project.

https://bitbucket.org/LuLNope/xmlvalue_adapter_test_case/src/master/

In the repository you can find 4 classes wih main method:

  • Case1WithAdapter - executing this class will result in NPE at com.sun.xml.bind.v2.runtime.FilterTransducer.useNamespace(FilterTransducer.java:37)
  • Case1MainNoAdapter - this is the exact same case as previous class without any adapter used. Executing this main does not produce any errors.
  • Case2MainWithAdapter - executing this class will result in NPE at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor.get(TransducedAccessor.java:136)
  • Case2MainNoAdapter - this is the exact same case as previous class without any adapter used. Executing this main does not produce any errors.

lulnope avatar May 18 '23 11:05 lulnope

Hi @lulnope : This issue is not specific to 2.3.8 Same issue with 2.3.3

laurentschoelens avatar Sep 05 '23 07:09 laurentschoelens

Your XMLAdapter is not well defined. By changing from extends XmlAdapter<Object, LocalDate> to extends XmlAdapter<String, LocalDate>, your code will work as expected.

laurentschoelens avatar Sep 05 '23 08:09 laurentschoelens

@lukasj : this issue can be closed I think

laurentschoelens avatar Dec 08 '23 22:12 laurentschoelens