The problem here is that JiBX for some reason things the B class mapping 
does not extend the Ref class mapping. Given your binding, this should 
work, so I'm not sure where the problem is arising.

I suggest you first double-check to make sure that all your classes are 
up to date (so clean all the class files and rebuild). If they are, and 
you're still getting the problem, bundle up the code along with an Ant 
build script and enter a Jira bug report (see 
http://jibx.sourceforge.net/bugs.html). I'll try to check it out 
sometime soon.

  - Dennis

Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Varghese wrote:
> Hi,
>
> I get this exception while running an example
>  org.jibx.runtime.JiBXException: Mapping for type B must extend 
> abstract mapping for type Ref.
>
> It looks like the error is cause of the way the mapping defines that B 
> extends A and B extends Ref.
> <mapping name="b"
>             class="B"
>            * extends="A"*>
>         <structure map-as="A" />
>         <value name="bVal" field="b"/>
>     </mapping>
>
> A similar error has been reported at 
> http://www.mail-archive.com/jibx-users@lists.sourceforge.net/msg01288.html
> but did not see any resolution in the thread.
>
> I am only a couple of days old in JiBX land. Any help, references will 
> be highly appreciated.
>
> My scenario is as follows:
> Classes :
> --------
> class RefHolder {
>     public Ref ref;
> }
>
> abstract class Ref{
>     int refId;
> }
>
> class A extends Ref{
>     int a;
> }
>
> class B extends A{
>     int b;
> }
>
> Binding :
> ---------
> <binding>
>     <mapping name="refHolder" class="RefHolder">
>         <structure field="ref"/>
>     </mapping>
>    
>     <mapping class="Ref"
>             abstract="true">
>         <value name="refId" field="refId"/>
>     </mapping>
>
>     <mapping name="a"
>             class="A"
>             extends="Ref">
>         <structure map-as="Ref" />
>         <value name="aVal" field="a"/>
>     </mapping>
>
>     <mapping name="b"
>             class="B"
>             extends="A">
>         <structure map-as="A" />
>         <value name="bVal" field="b"/>
>     </mapping>
> </binding>
>
> Main Class:
> ------------
> public class RefHolderTest {
>
>     public static void main(String[] args) throws JiBXException {
>         IBindingFactory bindingFactory = 
> BindingDirectory.getFactory(RefHolder.class);
>         IMarshallingContext mctx = 
> bindingFactory.createMarshallingContext();
>         mctx.setIndent(2);
>        
>         RefHolder refHolderB = new RefHolder();
>         B b = new B();
>         b.b=100;
>         refHolderB.ref = b;
>         mctx.marshalDocument(refHolderB, "UTF-8", null, System.out);
>        
>     }
> }
>
> Exception details:
> --------------------
> Exception in thread "main" org.jibx.runtime.JiBXException: Mapping for 
> type B must extend abstract mapping for type Ref
>     at JiBX_JiBXCustomizationXMLTest_bindingRef_access.baseMarshal()
>     at 
> RefHolder.JiBX_JiBXCustomizationXMLTest_binding_marshal_1_0(RefHolder.java)
>     at JiBX_JiBXCustomizationXMLTest_bindingRefHolder_access.marshal()
>     at RefHolder.marshal(RefHolder.java)
>     at 
> org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingContext.java:1035)
>     at 
> org.jibx.runtime.impl.MarshallingContext.marshalDocument(MarshallingContext.java:1127)
>     at RefHolderTest.main(RefHolderTest.java:38)
>
> regards
> vcv
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to