Results 1 to 2 of 2

Thread: JAXB nullpointer when marshalling a null date value

  1. #1

    Default JAXB nullpointer when marshalling a null date value

    Hi all,

    I have a custom XmlAdapter to Marshal org.joda.time.DateTime to xsate

    Code:
    public String marshal(YearMonthDay v) {
    		if (v.getYearMonthDay() != null) {
    			return v.getYearMonthDay()
    					.toString(DateTimeFormat.forPattern("YYYY-MM-dd"));
    		} else {
    			return null;
    		}
    	}
    When I return a null value (if the value is null) I will receive a nullpointer in JAXB:

    Code:
    Caused by: java.lang.NullPointerException
    	at com.sun.xml.internal.bind.v2.runtime.output.SAXOutput.text(SAXOutput.java:114)
    So my question is: Is it illegal to return null here? If so how to deal with null values?

    Thanks in advance.

    Regards,

  2. #2

    Default JAXB issue


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •