Hello All,

I've written a little xdoclet to generate the binding files for my java
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        status;
  Type  type;
}

public class Type{
  String        name;
}

public class Status{
  String        name;
}

Using the following binding works fine:

<?xml version='1.0' encoding='UTF-8'?>
<binding>

  <mapping name="status" class="Status">
    <value name="name" field="name"/>
  </mapping>

  <mapping name="type" class="Type">
    <value name="name" field="name"/>
  </mapping>
  
  <mapping name="someObj" class="SomeObject">
    <structure field="status"/>
    <structure field="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 

<?xml version='1.0' encoding='UTF-8'?>
<binding>
  <mapping name="status" class="Status">
    <value name="name" field="name"/>
  </mapping>
</binding>

<?xml version='1.0' encoding='UTF-8'?>
<binding> 
  <mapping name="someObj" class="SomeObject">
    <structure field="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(MarshallingCon
text.java:905)
        at Status.marshal(Status.java)
        at SomeObject.JiBX_conf_SomeObject_marshal_1_0(SomeObject.java)
        at JiBX_conf_SomeObjectSomeObject_access.marshal()
        at SomeObject.marshal(SomeObject.java)
        at
org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingConte
xt.java:964)
        at
org.jibx.runtime.impl.MarshallingContext.marshalDocument(MarshallingC
ontext.java:1056)
        at Run.main(Run.java:29)


Now if I try to include both type and status in my mapping: 

<?xml version='1.0' encoding='UTF-8'?>
<binding>
  <mapping name="someObj" class="SomeObject">
    <structure field="status"/>
    <structure field="type"/>
  </mapping>
</binding> 

I have a binding error:


Using bindings:
 conf/SomeObject.jibx.xml
Running binding compiler version jibx-rc0
binding conf_SomeObject:
 context (mp#=1) (cv#=0) (fm#=0)
  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 JiBX
users li
st so that the condition can be caught during validation ***

java.lang.IllegalStateException: Internal error: Too few values on stack
 full stack:
  0: Type

        at
org.jibx.binding.classes.MethodBuilder.verifyStackDepth(MethodBuilder
java:432)
        at
org.jibx.binding.classes.MethodBuilder.verifyStack(MethodBuilder.java
: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:15
6)
        at
org.jibx.binding.def.DirectGeneric.genContentUnmarshal(DirectGeneric.
java:230)
        at
org.jibx.binding.def.PassThroughComponent.genContentUnmarshal(PassThr
oughComponent.java:111)
        at
org.jibx.binding.def.NestedStructure.genContentUnmarshal(NestedStruct
ure.java:153)
        at
org.jibx.binding.def.ObjectBinding.genUnmarshalContentCall(ObjectBind
ing.java:736)
        at
org.jibx.binding.def.ObjectBinding.genContentUnmarshal(ObjectBinding.
java:875)
        at
org.jibx.binding.def.ElementWrapper.genContentUnmarshal(ElementWrappe
r.java:272)
        at
org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinition
java:541)
        at
org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContext
java:600)
        at
org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinition
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 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

Reply via email to