Incidentally, I did take care of detecting the situation you'd originally reported as giving a Runtime exception. It turned out to be a lot more complex than I'd originally anticipated, so kept me busy for most of the time I was conscious in the 30-hour transit time going Seattle->Los Angeles->Sydney->Wellington.
- Dennis
Arnaud Lenfant wrote:
Thanks for the quick answer, Dennis.
<include> would help me, but as I understand it searches for locations relative to the inclusing file.
When I have:
Import somePackage.Type
public class SomeObject { Type type; }
I have no idea of the location of somePackage relative to my class, I just assume it is in the classpath. Would it be possible to have <include> lookup for binding files as resources ?
Regards,
Arnaud
Subject: Re: [jibx-users] Issue with splitting binding files To: jibx-users@lists.sourceforge.net Reply-To: jibx-users@lists.sourceforge.net
Hi Arnaud,
You should be able to do what you want by using <include>:
<binding> <include path=3D"type-binding.xml"/> <include path=3D"status-binding.xml"/> <mapping name=3D"someObj" ...
I'm surprised that your binding:
<binding> <mapping name=3D"someObj" class=3D"SomeObject"> <structure field=3D"status"/> <structure field=3D"type"/> </mapping> </binding>=20
got as far as it did (into code generation). This should have been= =20 rejected before the code generation phase because there was no mappin= g=20 defined within this binding for the types of the fields.
- Dennis
Arnaud Lenfant wrote:
avaHello All,
I've written a little xdoclet to generate the binding files for my j=
inclasses. I generate a xxx.binding.xml for every xxx.java. But I'm not sure it's the right way to do things with Jibx.
I have the following classes:
public class SomeObject { Status=09status; Type=09type; }
public class Type{ String=09name; }
public class Status{ String=09name; }
Using the following binding works fine:
<?xml version=3D'1.0' encoding=3D'UTF-8'?> <binding>
<mapping name=3D"status" class=3D"Status"> <value name=3D"name" field=3D"name"/> </mapping>
<mapping name=3D"type" class=3D"Type"> <value name=3D"name" field=3D"name"/> </mapping> =20 <mapping name=3D"someObj" class=3D"SomeObject"> <structure field=3D"status"/> <structure field=3D"type"/> </mapping>
</binding>
But if I split the bindings and put the bindings for Type and Status=
)different files I have the following errors:
With=20
<?xml version=3D'1.0' encoding=3D'UTF-8'?> <binding> <mapping name=3D"status" class=3D"Status"> <value name=3D"name" field=3D"name"/> </mapping> </binding>
<?xml version=3D'1.0' encoding=3D'UTF-8'?> <binding>=20 <mapping name=3D"someObj" class=3D"SomeObject"> <structure field=3D"status"/> </mapping> </binding>
The binding works allright but I have a runtime exception:
Exception in thread "main" java.lang.NullPointerException
at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
at java.security.AccessController.doPrivileged(Native Method=
at java.net.URLClassLoader.findClass(URLClassLoader.java:187=)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:282)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:=
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)n
at
org.jibx.runtime.impl.MarshallingContext.getMarshaller(MarshallingCo=
text.java:905)va)
at Status.marshal(Status.java)
at SomeObject.JiBX_conf_SomeObject_marshal_1_0(SomeObject.ja=
at JiBX_conf_SomeObjectSomeObject_access.marshal()e
at SomeObject.marshal(SomeObject.java)
at
org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingCont=
xt.java:964)C
at
org.jibx.runtime.impl.MarshallingContext.marshalDocument(Marshalling=
iBXontext.java:1056) at Run.main(Run.java:29)
Now if I try to include both type and status in my mapping:=20
<?xml version=3D'1.0' encoding=3D'UTF-8'?> <binding> <mapping name=3D"someObj" class=3D"SomeObject"> <structure field=3D"status"/> <structure field=3D"type"/> </mapping> </binding>=20
I have a binding error:
Using bindings: conf/SomeObject.jibx.xml Running binding compiler version jibx-rc0 binding conf_SomeObject: context (mp#=3D1) (cv#=3D0) (fm#=3D0) mapping class SomeObject to element someObj element wrapper someObj object binding for SomeObject structure ordered mapping reference to Status using property status (Status) mapping reference to Type using property type (Type) Generating code for mapping SomeObject Error running binding compiler
*** Error during code generation - please report this error on the J=
tackusers li st so that the condition can be caught during validation ***
java.lang.IllegalStateException: Internal error: Too few values on s=
rfull stack: 0: Type
at
org.jibx.binding.classes.MethodBuilder.verifyStackDepth(MethodBuilde=
java:432)a
at
org.jibx.binding.classes.MethodBuilder.verifyStack(MethodBuilder.jav=
:459)j
at
org.jibx.binding.classes.MethodBuilder.appendPutField(MethodBuilder.=
ava:743)7
at
org.jibx.binding.classes.MethodBuilder.appendPut(MethodBuilder.java:=
72)j
at
org.jibx.binding.def.PropertyDefinition.genStore(PropertyDefinition.=
ava:520)5
at
org.jibx.binding.def.DirectGeneric.genUnmarshal(DirectGeneric.java:1=
6)
at
org.jibx.binding.def.DirectGeneric.genContentUnmarshal(DirectGeneric=
java:230)r
at
org.jibx.binding.def.PassThroughComponent.genContentUnmarshal(PassTh=
oughComponent.java:111)t
at
org.jibx.binding.def.NestedStructure.genContentUnmarshal(NestedStruc=
ure.java:153)d
at
org.jibx.binding.def.ObjectBinding.genUnmarshalContentCall(ObjectBin=
ing.java:736)
at
org.jibx.binding.def.ObjectBinding.genContentUnmarshal(ObjectBinding=
java:875)e
at
org.jibx.binding.def.ElementWrapper.genContentUnmarshal(ElementWrapp=
r.java:272)n
at
org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinitio=
java:541)t
at
org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContex=
java:600)n
at
org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinitio=
ofjava:578) at org.jibx.binding.Compile.compile(Compile.java:303) at org.jibx.binding.Compile.main(Compile.java:382)
So clearly I'm doing something wrong. Is there a way to separate the binding files for different classes ?
In my case the Status and Type classes would be referenced by a lot =
different classes. What I'd like is a way to generate their mapping =once
ers.and have it used whenever it is needed.
Thanks for your help,
Arnaud Lenfant
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real us=
Discover which products truly live up to the hype. Start reading now=
http://ads.osdn.com/?ad_ide95&alloc_id=14396&op=CCk _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users
=20
--__--__--
_______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users
End of jibx-users Digest
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&opĚk _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users