I have created the bug report in Jira with the ant build as requested -
http://jira.codehaus.org/browse/JIBX-150. Please do verify if its
acceptable.
If the mapping for B specifies extends="Ref" as opposed to extends="A",
there are no runtime errors.
B's mapping now looks like
<mapping name="b"
class="B"
extends="Ref">
<structure map-as="A" />
<value name="bVal" field="b"/>
</mapping>
JiBX now generates the xml with <b> tags enclosing <a> tags, which is
not what I intended, there should not be any <a> tags
<?xml version="1.0" encoding="UTF-8"?>
<refHolder>
<b>
<a>
<refId>0</refId>
<aVal>0</aVal>
</a>
<bVal>100</bVal>
</b>
</refHolder>
I will apply this workaround for now.
Thank you for your help and quick responses.
Regards
Varghese
[EMAIL PROTECTED] wrote:
> Date: Thu, 25 Jan 2007 08:05:08 +1300
> From: Dennis Sosnoski <[EMAIL PROTECTED]>
> Subject: Re: [jibx-users] Mapping must extend abstract mapping
> To: JiBX users <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> 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/[email protected]/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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users