Hi Mark,

You should be able to do this without a problem if you just drop the extends="DomainObjectTranslation" from your mapping. The whole extends="..." approach is really only appropriate for a very small set of use cases these days; I've updated the binding tutorial to reflect this somewhat (though now I wonder if I should even mention them at all). You can view the new tutorial at http://www.sosnoski.com/jibx-site/tutorial/binding-tutorial.html

Really the main thing that extends="..." does for you these days is give a warning when you don't reference the base mapping. The approach of just using plain (non-extended) abstract mappings is much more flexible and powerful.

 - Dennis

Mark Wutka wrote:

I am trying to map a fairly large set of domain objects using JiBX and I
have run into a tricky situation. I have an abstract base class called
DomainObjectTranslation that contains a locale for a translation. Then
there are different subclasses of DomainObjectTranslation like
FeatureTypeTranslation, CurrencyTranslation, etc.

My first problem is that java.util.Locale doesn't have a no-arg
constructor, so as far as I can tell, I have to do a custom marshaller
for DomainObjectTranslation. Added on top of this is the complication
that the locale values appear as attributes, like:
<featureTypeTranslation isoLanguageCode="de" isoCountryCode="DE">

I believe that I can do this with a custom marshaller and have written
one. It appears, though, that I can't use a custom marshaller for the
abstract base class while using regular JiBX mapping for the subclasses.
I'm not entirely surprised at this, but I am hoping that maybe there is
still a workable solution here. Anyway, I am getting this error when I
try to run the binding compiler:

Error running binding compiler

*** Error during code generation - please report this error on the JiBX
users list so that the condition can be caught during validation ***

java.lang.IllegalStateException: Internal error: no extension possible
   at
org.jibx.binding.def.MappingDirect.addExtension(MappingDirect.java:120)
   at
org.jibx.binding.def.MappingDefinition.linkMappings(MappingDefinition.java:258)
   at
org.jibx.binding.def.DefinitionContext.linkMappings(DefinitionContext.java:623)
   at
org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinition.java:609)
   at org.jibx.binding.Compile.compile(Compile.java:305)
   at org.jibx.binding.Compile.main(Compile.java:384)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:86)



The relevant parts of my binding.xml are:
<mapping class="DomainObjectTranslation" abstract="true"
   marshaller="DomainObjectTranslationMarshaller"
   unmarshaller="DomainObjectTranslationMarshaller">
</mapping>

<mapping class="FeatureTypeTranslation" name="featureTypeTranslation"
   extends="DomainObjectTranslation">
   <structure map-as="DomainObjectTranslation"/>
   <value name="description" field="featureDesc" usage="optional"/>
</mapping>


Any suggestions?
 Mark


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to