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

StackOverflow https://stackoverflow.com/questions/18490707

문제

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!

도움이 되었습니까?

해결책

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

다른 팁

You can use the @XmlElement annotation to specify an implementing class of the Status interface.

@XmlElement(type=SomeStatusImpl.class)
public List<Status> getStatuses() {
    return statuses;
}

For More Information

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top