JiBX
  1. JiBX
  2. JIBX-274

Compiler produces difference jibx classes when using bindingfileset and binding ant tasks

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: JiBX 1.1.6
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      windows
    • Number of attachments :
      2

      Description

      Sorry not sure if this is core or generation tool, but it is ant ant compiler.

      I think that the 2 examples are equivalent but they produce significantly different class output files.
      When they are separate, my application complains that it can't find the bind files.

      <bind verbose="true" load="false">
      <classpath>
      <pathelement path="$

      {output-dir}/dino"/>
      <pathelement location="${jibx-lib}/jibx-run.jar"/>
      </classpath>
      <bindingfileset dir="${root}/Java/dino/src/main/java/com/mycom/dino/config/jibx">
      <include name="*.jibx.xml"/>
      </bindingfileset>
      </bind>

      gives:

      bus_dino:
      [bind] Using the following paths:
      [bind] c:\dino_build\dino
      [bind] Z:\Quentin\ManagerLibs\jibx\latest\lib\jibx-run.jar
      [bind] Using the following binding paths:
      [bind] Z:\Quentin\Java\dino\src\main\java\com\mycom\dino\config\jibx\clipproperties.jibx.xml
      [bind] Z:\Quentin\Java\dino\src\main\java\com\mycom\dino\config\jibx\clippropertieslist.jibx.xml
      [bind] Z:\Quentin\Java\dino\src\main\java\com\mycom\dino\config\jibx\cliprushparts.jibx.xml
      [bind] Running binding compiler version jibx_1_1_6a
      [bind] binding clipproperties:
      [bind] context (mp#=2) (cv#=1) (fm#=0)
      [bind] mapping direct java.util.Map
      [bind] mapping class com.mycom.dino.web.buckets.ClipProperties to element clipproperties (#1)
      [bind] context (cv#=0) (fm#=0)
      [bind] element wrapper clipproperties
      [bind] object binding for com.mycom.dino.web.buckets.ClipProperties create class com.mycom.dino.web.buckets.ClipProperties
      [bind] structure ordered
      [bind] element id from property id (java.util.UUID)
      [bind] mapping reference to java.util.Map using property properties (java.util.Map)
      [bind] binding clippropertieslist:
      [bind] context (mp#=2) (cv#=1) (fm#=0)
      [bind] mapping direct java.util.Map
      [bind] mapping class com.mycom.dino.web.buckets.ClipPropertiesList to element clippropertieslist (#2)
      [bind] context (cv#=0) (fm#=0)
      [bind] element wrapper clippropertieslist
      [bind] object binding for com.mycom.dino.web.buckets.ClipPropertiesList create class com.mycom.dino.web.buckets.ClipPropertiesList
      [bind] structure ordered
      [bind] component property list (java.util.List)
      [bind] object binding for java.util.List create class java.util.List
      [bind] collection ordered (java.lang.Object)
      [bind] element wrapper clipproperties direct
      [bind] component property from collection (com.mycom.dino.web.buckets.ClipProperties)
      [bind] object binding for com.mycom.dino.web.buckets.ClipProperties create class com.mycom.dino.web.buckets.ClipProperties
      [bind] structure ordered
      [bind] element id from property id (java.util.UUID)
      [bind] mapping reference to java.util.Map using property properties (java.util.Map)
      [bind] binding cliprushparts:
      [bind] context (mp#=1) (cv#=4) (fm#=0)
      [bind] mapping class com.mycom.dino.web.buckets.ClipRushParts to element rushparts (#3)
      [bind] context (cv#=0) (fm#=0)
      [bind] element wrapper rushparts
      [bind] object binding for com.mycom.dino.web.buckets.ClipRushParts create class com.mycom.dino.web.buckets.ClipRushParts
      [bind] structure ordered
      [bind] element id from property id (java.util.UUID)
      [bind] component property rushparts (java.util.Collection)
      [bind] object binding for java.util.Collection create class java.util.Collection
      [bind] collection ordered (java.lang.Object)
      [bind] element wrapper rushpart direct
      [bind] component property from collection (com.mycom.dino.bus.RushPart)
      [bind] object binding for com.mycom.dino.bus.RushPart create class com.mycom.dino.bus.RushPart
      [bind] structure ordered
      [bind] element clipid from property clip (com.mycom.dino.bus.Clip)
      [bind] element rushid from property rushId (java.util.UUID)
      [bind] element start from property start (int)
      [bind] element finish from property finish (int)
      [bind] element trackno from property trackNo (int)
      [bind] element tracktype from property trackType (int)
      [bind] element clipstart from property clipStart (int)
      [bind] element format from property format (com.mycom.dino.bus.Format)
      [bind] Generating code for mapping java.util.Map
      [bind] Generating code for mapping com.mycom.dino.web.buckets.ClipProperties
      [bind] Generating code for mapping java.util.Map
      [bind] Generating code for mapping com.mycom.dino.web.buckets.ClipPropertiesList
      [bind] Generating code for mapping com.mycom.dino.web.buckets.ClipRushParts
      [bind]
      [bind] Wrote 9 files
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_MungeAdapter output file size is 3241 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_clippropertiesClipProperties_access output file size is 1959 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_clippropertiesHashMapper_0 output file size is 473 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_clippropertiesFactory output file size is 2788 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_clippropertieslistClipPropertiesList_access output file size is 1999 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_clippropertieslistHashMapper_0 output file size is 481 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_clippropertieslistFactory output file size is 2808 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_cliprushpartsClipRushParts_access output file size is 1945 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_cliprushpartsFactory output file size is 2740 bytes
      [bind]
      [bind] Kept 4 files unchanged:
      [bind] com.mycom.dino.web.buckets.ClipProperties
      [bind] com.mycom.dino.web.buckets.ClipPropertiesList
      [bind] com.mycom.dino.web.buckets.ClipRushParts
      [bind] com.mycom.dino.bus.RushPart
      [bind]
      [bind] Deleted 0 files:

      files:

      24/02/2009 11:33 4,149 ClipProperties.class
      24/02/2009 11:33 4,010 ClipPropertiesList.class
      24/02/2009 11:33 3,788 ClipRushParts.class
      24/02/2009 13:01 3,241 JiBX_MungeAdapter.class
      24/02/2009 13:01 473 JiBX_clippropertiesHashMapper_0.class
      24/02/2009 13:01 1,959 JiBX_clippropertiesClipProperties_access.class
      24/02/2009 13:01 481 JiBX_clippropertieslistHashMapper_0.class
      24/02/2009 13:01 1,999 JiBX_clippropertieslistClipPropertiesList_access.class
      24/02/2009 13:01 2,788 JiBX_clippropertiesFactory.class
      24/02/2009 13:01 2,808 JiBX_clippropertieslistFactory.class
      24/02/2009 13:01 1,945 JiBX_cliprushpartsClipRushParts_access.class
      24/02/2009 13:01 2,740 JiBX_cliprushpartsFactory.class

      ==================

      Using:

      <bind verbose="true" load="false" binding="${root}/Java/dino/src/main/java/com/mycom/dino/config/jibx/clipproperties.jibx.xml">
      <classpath>
      <pathelement path="${output-dir}

      /dino"/>
      <pathelement location="$

      {jibx-lib}/jibx-run.jar"/>
      </classpath>
      </bind>

      <bind verbose="true" load="false" binding="${root}/Java/dino/src/main/java/com/mycom/dino/config/jibx/clippropertieslist.jibx.xml">
      <classpath>
      <pathelement path="${output-dir}/dino"/>
      <pathelement location="${jibx-lib}

      /jibx-run.jar"/>
      </classpath>
      </bind>

      <bind verbose="true" load="false" binding="$

      {root}

      /Java/dino/src/main/java/com/mycom/dino/config/jibx/cliprushparts.jibx.xml">
      <classpath>
      <pathelement path="$

      {output-dir}

      /dino"/>
      <pathelement location="$

      {jibx-lib}

      /jibx-run.jar"/>
      </classpath>
      </bind>

      gives:

      bus_dino:
      [bind] Using the following paths:
      [bind] c:\dino_build\dino
      [bind] Z:\Quentin\ManagerLibs\jibx\latest\lib\jibx-run.jar
      [bind] Using the following binding paths:
      [bind] /Quentin/Java/dino/src/main/java/com/mycom/dino/config/jibx/clipproperties.jibx.xml
      [bind] Running binding compiler version jibx_1_1_6a
      [bind] binding _Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clipproperties:
      [bind] context (mp#=2) (cv#=1) (fm#=0)
      [bind] mapping direct java.util.Map
      [bind] mapping class com.mycom.dino.web.buckets.ClipProperties to element clipproperties (#1)
      [bind] context (cv#=0) (fm#=0)
      [bind] element wrapper clipproperties
      [bind] object binding for com.mycom.dino.web.buckets.ClipProperties create class com.mycom.dino.web.buckets.ClipProperties
      [bind] structure ordered
      [bind] element id from property id (java.util.UUID)
      [bind] mapping reference to java.util.Map using property properties (java.util.Map)
      [bind] Generating code for mapping java.util.Map
      [bind] Generating code for mapping com.mycom.dino.web.buckets.ClipProperties
      [bind]
      [bind] Wrote 5 files
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_MungeAdapter output file size is 300 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.ClipProperties output file size is 4874 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertiesClipProperties_access output file size is 2083 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertiesHashMapper_0 output file size is 597 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertiesFactory output file size is 2987 bytes
      [bind]
      [bind] Kept 0 files unchanged:
      [bind]
      [bind] Deleted 0 files:
      [bind] Using the following paths:
      [bind] c:\dino_build\dino
      [bind] Z:\Quentin\ManagerLibs\jibx\latest\lib\jibx-run.jar
      [bind] Using the following binding paths:
      [bind] /Quentin/Java/dino/src/main/java/com/mycom/dino/config/jibx/clippropertieslist.jibx.xml
      [bind] Running binding compiler version jibx_1_1_6a
      [bind] binding _Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertieslist:
      [bind] context (mp#=2) (cv#=1) (fm#=0)
      [bind] mapping direct java.util.Map
      [bind] mapping class com.mycom.dino.web.buckets.ClipPropertiesList to element clippropertieslist (#1)
      [bind] context (cv#=0) (fm#=0)
      [bind] element wrapper clippropertieslist
      [bind] object binding for com.mycom.dino.web.buckets.ClipPropertiesList create class com.mycom.dino.web.buckets.ClipPropertiesList
      [bind] structure ordered
      [bind] component property list (java.util.List)
      [bind] object binding for java.util.List create class java.util.List
      [bind] collection ordered (java.lang.Object)
      [bind] element wrapper clipproperties direct
      [bind] component property from collection (com.mycom.dino.web.buckets.ClipProperties)
      [bind] object binding for com.mycom.dino.web.buckets.ClipProperties create class com.mycom.dino.web.buckets.ClipProperties
      [bind] structure ordered
      [bind] element id from property id (java.util.UUID)
      [bind] mapping reference to java.util.Map using property properties (java.util.Map)
      [bind] Generating code for mapping java.util.Map
      [bind] Generating code for mapping com.mycom.dino.web.buckets.ClipPropertiesList
      [bind]
      [bind] Wrote 5 files
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_MungeAdapter output file size is 2489 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.ClipProperties output file size is 4668 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertieslistClipPropertiesList_access output file size is 2247 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertieslistHashMapper_0 output file size is 605 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertieslistFactory output file size is 3011 bytes
      [bind]
      [bind] Kept 2 files unchanged:
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertiesHashMapper_0
      [bind] com.mycom.dino.web.buckets.ClipPropertiesList
      [bind]
      [bind] Deleted 3 files:
      [bind] com.mycom.dino.web.buckets.JiBX_MungeAdapter
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertiesClipProperties_access
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertiesFactory
      [bind] Using the following paths:
      [bind] c:\dino_build\dino
      [bind] Z:\Quentin\ManagerLibs\jibx\latest\lib\jibx-run.jar
      [bind] Using the following binding paths:
      [bind] /Quentin/Java/dino/src/main/java/com/mycom/dino/config/jibx/cliprushparts.jibx.xml
      [bind] Running binding compiler version jibx_1_1_6a
      [bind] binding _Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_cliprushparts:
      [bind] context (mp#=1) (cv#=4) (fm#=0)
      [bind] mapping class com.mycom.dino.web.buckets.ClipRushParts to element rushparts (#0)
      [bind] context (cv#=0) (fm#=0)
      [bind] element wrapper rushparts
      [bind] object binding for com.mycom.dino.web.buckets.ClipRushParts create class com.mycom.dino.web.buckets.ClipRushParts
      [bind] structure ordered
      [bind] element id from property id (java.util.UUID)
      [bind] component property rushparts (java.util.Collection)
      [bind] object binding for java.util.Collection create class java.util.Collection
      [bind] collection ordered (java.lang.Object)
      [bind] element wrapper rushpart direct
      [bind] component property from collection (com.mycom.dino.bus.RushPart)
      [bind] object binding for com.mycom.dino.bus.RushPart create class com.mycom.dino.bus.RushPart
      [bind] structure ordered
      [bind] element clipid from property clip (com.mycom.dino.bus.Clip)
      [bind] element rushid from property rushId (java.util.UUID)
      [bind] element start from property start (int)
      [bind] element finish from property finish (int)
      [bind] element trackno from property trackNo (int)
      [bind] element tracktype from property trackType (int)
      [bind] element clipstart from property clipStart (int)
      [bind] element format from property format (com.mycom.dino.bus.Format)
      [bind] Generating code for mapping com.mycom.dino.web.buckets.ClipRushParts
      [bind]
      [bind] Wrote 3 files
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX_MungeAdapter output file size is 2463 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_cliprushpartsClipRushParts_access output file size is 2193 bytes
      [bind]
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_cliprushpartsFactory output file size is 2859 bytes
      [bind]
      [bind] Kept 2 files unchanged:
      [bind] com.mycom.dino.web.buckets.ClipRushParts
      [bind] com.mycom.dino.bus.RushPart
      [bind]
      [bind] Deleted 5 files:
      [bind] com.mycom.dino.web.buckets.JiBX_MungeAdapter
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertiesHashMapper_0
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertieslistClipPropertiesList_access
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertieslistFactory
      [bind] com.mycom.dino.web.buckets.JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_clippropertieslistHashMapper_0

      files:

      24/02/2009 13:04 4,475 ClipPropertiesList.class
      24/02/2009 13:04 4,233 ClipRushParts.class
      24/02/2009 13:11 4,668 ClipProperties.class
      24/02/2009 13:11 2,463 JiBX_MungeAdapter.class
      24/02/2009 13:11 2,193 JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_cliprushpartsClipRushParts_access.class
      24/02/2009 13:11 2,859 JiBX__Quentin_Java_dino_src_main_java_com_mycom_dino_config_jibx_cliprushpartsFactory.class

      1. build.xml-output.txt
        17 kB
        Nuno Belo
      2. exception.txt
        0.7 kB
        Nuno Belo

        Activity

        Hide
        T.J. Hill added a comment -

        Same problem here. Seems that If I have two separate projects that each are compiled independently of one another – each project has its own JiBX compilation task (using the binding attribute in the bind task since these are separate). When the build steps for the two independent projects are executed as part of a larger build script, the compilation for the first project encountered executes fine – the compiler updates/generates any needed classes for the first project. When the compilation for the second project executes, the compiler updates/generates any needed classes for the second project, but also deletes one or more generated JiBX classes that were written by the first compilation – for the first project – which is unexpected. My experience is exactly what David illustrates in his second scenario.

        Show
        T.J. Hill added a comment - Same problem here. Seems that If I have two separate projects that each are compiled independently of one another – each project has its own JiBX compilation task (using the binding attribute in the bind task since these are separate). When the build steps for the two independent projects are executed as part of a larger build script, the compilation for the first project encountered executes fine – the compiler updates/generates any needed classes for the first project. When the compilation for the second project executes, the compiler updates/generates any needed classes for the second project, but also deletes one or more generated JiBX classes that were written by the first compilation – for the first project – which is unexpected. My experience is exactly what David illustrates in his second scenario.
        Hide
        Dennis Sosnoski added a comment -

        This is an issue which should really be mentioned in the documentation (I thought it was, but in a quick look I don't see anything).

        The binding compiler looks over the code you provide and cleans up any classes or class modifications from prior executions of the binding compiler. This is by design, since it allows you to rerun the binding compiler anytime you want without worrying about whether or which classes have changed. But it means that if you're using multiple bindings for classes in the same package, you need to compile all those bindings at the same time.

        I'll make sure this is covered in the documentation, and perhaps also add a warning message to the binding compiler output if it looks like you might be stepping on other bindings.

        Show
        Dennis Sosnoski added a comment - This is an issue which should really be mentioned in the documentation (I thought it was, but in a quick look I don't see anything). The binding compiler looks over the code you provide and cleans up any classes or class modifications from prior executions of the binding compiler. This is by design, since it allows you to rerun the binding compiler anytime you want without worrying about whether or which classes have changed. But it means that if you're using multiple bindings for classes in the same package, you need to compile all those bindings at the same time. I'll make sure this is covered in the documentation, and perhaps also add a warning message to the binding compiler output if it looks like you might be stepping on other bindings.
        Hide
        Nuno Belo added a comment -

        Hi Dennis,

        I'm experiencing exactly the same issue and I've understood your explanation... my problem here is understanding what you mean by "But it means that if you're using multiple bindings for classes in the same package, you need to compile all those bindings at the same time."... are you saying that all binding code should be in a single file?

        the reason I'm asking is because in my Ant script I'm already performing the compilation and binding in one go and I still experience the problem. Help would be extremely appreciated

        thank you.
        cheers,
        Nuno Belo

        Note: please find below the build target from the Ant script and in attach the build output for reference; I'm also including the error I'm getting while running a sample test that requires unmarshalling two files (one associated with each of the bindings);

        <target depends="clean, init" name="build">
        <echo message="$

        {ant.project.name}

        : $

        {ant.file}

        " />

        <!-- Compile the Java sources using the standard compiler -->
        <javac debug="true"
        debuglevel="$

        {debuglevel}

        "
        destdir="bin"
        source="$

        {source}

        "
        target="$

        {target}

        ">

        <src path="src" />
        <classpath refid="compilation.classpath" />
        </javac>

        <!-- Run the JiBX binding compiler to generate the required binding classes -->
        <!-- NOTE: MULTIPLE BINDING FILES @ ONCE DOESN'T WORK PROPERLY -->
        <!-- https://jira.codehaus.org/browse/JIBX-274 -->
        <bind verbose="true" load="true">

        <classpathset dir="./bin"/>
        <bindingfileset dir="./bin/org/oretail/monitor/model/jibx">
        <include name="*-binding.xml" />
        </bindingfileset>
        </bind>
        </target>

        Show
        Nuno Belo added a comment - Hi Dennis, I'm experiencing exactly the same issue and I've understood your explanation... my problem here is understanding what you mean by "But it means that if you're using multiple bindings for classes in the same package, you need to compile all those bindings at the same time."... are you saying that all binding code should be in a single file? the reason I'm asking is because in my Ant script I'm already performing the compilation and binding in one go and I still experience the problem. Help would be extremely appreciated thank you. cheers, Nuno Belo Note: please find below the build target from the Ant script and in attach the build output for reference; I'm also including the error I'm getting while running a sample test that requires unmarshalling two files (one associated with each of the bindings); <target depends="clean, init" name="build"> <echo message="$ {ant.project.name} : $ {ant.file} " /> <!-- Compile the Java sources using the standard compiler --> <javac debug="true" debuglevel="$ {debuglevel} " destdir="bin" source="$ {source} " target="$ {target} "> <src path="src" /> <classpath refid="compilation.classpath" /> </javac> <!-- Run the JiBX binding compiler to generate the required binding classes --> <!-- NOTE: MULTIPLE BINDING FILES @ ONCE DOESN'T WORK PROPERLY --> <!-- https://jira.codehaus.org/browse/JIBX-274 --> <bind verbose="true" load="true"> <classpathset dir="./bin"/> <bindingfileset dir="./bin/org/oretail/monitor/model/jibx"> <include name="*-binding.xml" /> </bindingfileset> </bind> </target>

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            David Newcomb
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: