Hello,
I'm having trouble getting may package annotated @XmlJavaTypeAdapter to kick in:
com.Foo.java>>>
package com;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlRootElement;
import org.joda.time.DateTime;
@XmlRootElement
public class Foo {
private DateTime now = new DateTime();
public static void main(String[] args) throws Exception {
final JAXBContext jc = JAXBContext.newInstance("com");
Marshaller m = jc.createMarshaller();
m.marshal( new Foo(), System.out);
}
}
<<<
com.package-info.java>>>
@XmlJavaTypeAdapters(@XmlJavaTypeAdapter( type = DateTime.class, value = DateTimeAdapter.class))
package com;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import org.joda.time.DateTime;
import com.orchestral.orders.jaxb.adapters.DateTimeAdapter;
<<<
But my output is just:
<foo/>
If I add the annotation explicitly on the attribute (in Foo.java):
@XmlJavaTypeAdapter( DateTimeAdapter.class)
private DateTime now = new DateTime();
Then the ouput is as expected:
<foo><now>200609201741</now></foo>
Why isn't the package annotation working?
thanks,
Gary