开发者

JiBXException: Multiple bindings defined for class

Strange thing...

I have a binding definition user-wrapper.xml:

<binding>
    <include path="core-wrapper.xml" />
    <include path="user-composite-entity.xml" />

    <mapping name="users" class="UserWrapper" extends="CoreWrapper">
        <structure map-as="CoreWrapper" usage="optional" />
        <collection field="users" usage="optional" item-type="UserCompositeEntity">

        </collection>
    </mapping>
</binding>

Next I have this binding definition user-composite-entity.xml (included in upper file):

<binding>
    <include path="core-composite-entity.xml" />
    <include path="user-entity.xml" />

    <mapping name="user" class="UserCompositeEntity" extends="CoreCompositeEntity">
        <structure map-as="CoreCompositeEntity" />
        <structure field="userEntity" usage="optional" />
        <structure field="meta" marshaller="UserMetaHashMapper" unmarshaller="UserMetaHashMapper" usage="optional" />       
    </mapping>
</binding>

Now, if I call REST which uses binding user-wrapper.xml, mapping goes successfully through. If I call REST which uses binding user-composite-entity.xml I get the next error:

org.j开发者_开发问答ibx.runtime.JiBXException: Multiple bindings defined for class UserCompositeEntity

Now the strange thing (for me). If I remove from user-wrapper.xml <include path="user-composite-entity.xml" /> goes a like this: - call with user-composite-entity.xml is a succes, - call with user-wrapper.xml I get the error:

org.jibx.runtime.JiBXException: No marshaller defined for class UserCompositeEntity


This email thread seems to have some information.


How it works now: I don't have user-wrapper.xml anymore and user-composite-entity.xml looks like that:

<binding>
 <include path="core-wrapper.xml" />
 <include path="core-composite-entity.xml" />
 <include path="user-entity.xml" />

 <mapping name="users" class="UserWrapper" extends="CoreWrapper">
  <structure map-as="CoreWrapper" usage="optional" />
  <collection field="users" usage="optional" >   
  </collection>
 </mapping>

 <mapping name="user" class="UserCompositeEntity" extends="CoreCompositeEntity">
  <structure map-as="CoreCompositeEntity" />
  <structure field="userEntity" usage="optional" />
  <structure field="meta" marshaller="UserMetaHashMapper" unmarshaller="UserMetaHashMapper" usage="optional" />  
 </mapping>
</binding>

The problem was, because before I in user-wrapper.xml included user-composite-entity.xml and JiBX compiled it again (for user-wrapper.xml). That's why there were multiple binding definitions...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜