Search code examples
javamongodbjaxbtwitter4jmorphia

saving twitter4J Status to MongoDB gives "twitter4j.Status is an interface, and JAXB can't handle interfaces"


Trying to save a List<Status> to MongoDB (via Morphia), and I get this compile time error:

com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
twitter4j.Status is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at twitter4j.Status
        at public java.util.List Model.TwitterJob.getStatuses()

Any idea? Thanks a lot!


Solution

  • It's a little complicated to marshal Status, because the class StatusJSONImpl which implements Status in Twitter4j 3.0 is protected. You need to override the class and make it visible to your classes.

    Please checkout the following example for detail.

    https://github.com/phstudy/Twitter4j_JAXB_example