Announcement Announcement Module
Collapse
No announcement yet.
Unable to use Jaxb2Marshaller with an XmlAdapter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to use Jaxb2Marshaller with an XmlAdapter

    Hi,

    I'm facing the following problem (not related to WS directly, but I post here because of the JAXB component) :
    I want to Marshall a org.springframework.social.twitter.api.Tweet to xml. But this object does not have a no-arg constructor as the Jaxb2Marshaller says

    Code:
    Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    org.springframework.social.twitter.api.Tweet does not have a no-arg default constructor.
    	this problem is related to the following location:
    		at org.springframework.social.twitter.api.Tweet
    So I create a SimpleTweet class that simply propose the same get/set but with a default constructor.
    Then I create a TweetAdapter to link those two classes.

    Next, I change my Jaxb2Manager configuration like this.

    HTML Code:
    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <property name="classesToBeBound">
                <list>
                    <value>org.springframework.social.twitter.api.Tweet</value>
                </list>
            </property>
            <property name="adapters">
                <list>
                    <bean class="test.TweetAdapter" />
                </list>
            </property>
        </bean>
    But I still get the same error message. Do I forget something ?
    Note that I can't modify the original Tweet class to add an Annotation.

    Thanks in advance
    Last edited by Proner; Apr 18th, 2012, 05:22 PM.
Working...
X