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: [email protected]
Reply-To: [email protected]
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:
>Hello All,
>
>I've written a little xdoclet to generate the binding files for my j=
ava
>classes. 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=
in
>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)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:282)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:=
274)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
> at
>org.jibx.runtime.impl.MarshallingContext.getMarshaller(MarshallingCo=
n
>text.java:905)
> at Status.marshal(Status.java)
> at SomeObject.JiBX_conf_SomeObject_marshal_1_0(SomeObject.ja=
va)
> at JiBX_conf_SomeObjectSomeObject_access.marshal()
> at SomeObject.marshal(SomeObject.java)
> at
>org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingCont=
e
>xt.java:964)
> at
>org.jibx.runtime.impl.MarshallingContext.marshalDocument(Marshalling=
C
>ontext.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=
iBX
>users li
>st so that the condition can be caught during validation ***
>
>java.lang.IllegalStateException: Internal error: Too few values on s=
tack
> full stack:
> 0: Type
>
> at
>org.jibx.binding.classes.MethodBuilder.verifyStackDepth(MethodBuilde=
r
>java:432)
> at
>org.jibx.binding.classes.MethodBuilder.verifyStack(MethodBuilder.jav=
a
>:459)
> at
>org.jibx.binding.classes.MethodBuilder.appendPutField(MethodBuilder.=
j
>ava:743)
> at
>org.jibx.binding.classes.MethodBuilder.appendPut(MethodBuilder.java:=
7
>72)
> at
>org.jibx.binding.def.PropertyDefinition.genStore(PropertyDefinition.=
j
>ava:520)
> at
>org.jibx.binding.def.DirectGeneric.genUnmarshal(DirectGeneric.java:1=
5
>6)
> at
>org.jibx.binding.def.DirectGeneric.genContentUnmarshal(DirectGeneric=
>java:230)
> at
>org.jibx.binding.def.PassThroughComponent.genContentUnmarshal(PassTh=
r
>oughComponent.java:111)
> at
>org.jibx.binding.def.NestedStructure.genContentUnmarshal(NestedStruc=
t
>ure.java:153)
> at
>org.jibx.binding.def.ObjectBinding.genUnmarshalContentCall(ObjectBin=
d
>ing.java:736)
> at
>org.jibx.binding.def.ObjectBinding.genContentUnmarshal(ObjectBinding=
>java:875)
> at
>org.jibx.binding.def.ElementWrapper.genContentUnmarshal(ElementWrapp=
e
>r.java:272)
> at
>org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinitio=
n
>java:541)
> at
>org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContex=
t
>java:600)
> at
>org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinitio=
n
>java: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 =
of
>different classes. What I'd like is a way to generate their mapping =
once
>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=
ers.
>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
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/jibx-users
>
> =20
>
--__--__--
_______________________________________________
jibx-users mailing list
[email protected]
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=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users