JiBX
  1. JiBX
  2. JIBX-299

Setting default on an optional boolean value causes compiler error

    Details

    • Type: Improvement Improvement
    • Status: Reopened Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: JiBX 1.1.6
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      Ubuntu 9.04, running Ant build from Eclipse as a project builder.
    • Number of attachments :
      0

      Description

      I have an optional boolean property where I want the default value to be true rather than false, so I put in a binding like this:

      <value name="stationary" field="stationary" style="attribute" usage="optional" default="true" />

      This gave the following compiler error:
      [bind] *** Error during code generation for file 'binding.xml' - please enter a bug report for this error in Jira if the problem is not listed as fixed on the online status page ***
      [bind] org.jibx.runtime.JiBXException: Deserializer class org.jibx.runtime.Utility not found for converting default value
      [bind] at org.jibx.binding.def.PrimitiveStringConversion.convertDefault(PrimitiveStringConversion.java:412)
      [bind] at org.jibx.binding.def.PrimitiveStringConversion.derive(PrimitiveStringConversion.java:508)
      [bind] at org.jibx.binding.def.BindingBuilder.unmarshalValue(BindingBuilder.java:650)
      [bind] at org.jibx.binding.def.BindingBuilder.unmarshalStructureChildren(BindingBuilder.java:848)
      [bind] at org.jibx.binding.def.BindingBuilder.unmarshalMapping(BindingBuilder.java:1651)
      [bind] at org.jibx.binding.def.BindingBuilder.unmarshalMappings(BindingBuilder.java:983)
      [bind] at org.jibx.binding.def.BindingBuilder.unmarshalBindingDefinition(BindingBuilder.java:1799)
      [bind] at org.jibx.binding.Utility.loadBinding(Utility.java:293)
      [bind] at org.jibx.binding.Utility.loadFileBinding(Utility.java:413)
      [bind] at org.jibx.binding.Compile.compile(Compile.java:296)
      [bind] at org.jibx.binding.ant.CompileTask.execute(CompileTask.java:248)
      [bind] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
      [bind] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [bind] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [bind] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [bind] at java.lang.reflect.Method.invoke(Method.java:597)
      [bind] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
      [bind] at org.apache.tools.ant.Task.perform(Task.java:348)
      [bind] at org.apache.tools.ant.Target.execute(Target.java:357)
      [bind] at org.apache.tools.ant.Target.performTasks(Target.java:385)
      [bind] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
      [bind] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
      [bind] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      [bind] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
      [bind] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
      [bind] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
      [bind] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

      I then put in the type as follows, and got:
      <value name="stationary" field="stationary" style="attribute" usage="optional" default="true" type="boolean.default" />

      [bind] Error: Unable to load class boolean.default; on value element at (line 95, col 124, in binding.xml)

      It sounds like something is up with the classpath, but both the bind and the runtime jars are definitely on the ant task's classpath.

        Activity

        Hide
        Nigel Charman added a comment -

        I'm guessing you're missing jibx-run.jar from the classpath passed to the bind task. See the following from http://jibx.sourceforge.net/bindcomp.html:

        One issue to note with the Ant task is that if you're using default values you'll need to include the jibx-run.jar from the distribution in the classpath passed when you invoke the task:

        <!-- Run JiBX binding compiler -->
        <bind verbose="true" load="true" binding="binding.xml">
        <classpath>
        <pathelement path="classes"/>
        <pathelement location="$

        {jibx-lib}

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

        Show
        Nigel Charman added a comment - I'm guessing you're missing jibx-run.jar from the classpath passed to the bind task. See the following from http://jibx.sourceforge.net/bindcomp.html: One issue to note with the Ant task is that if you're using default values you'll need to include the jibx-run.jar from the distribution in the classpath passed when you invoke the task: <!-- Run JiBX binding compiler --> <bind verbose="true" load="true" binding="binding.xml"> <classpath> <pathelement path="classes"/> <pathelement location="$ {jibx-lib} /jibx-run.jar"/> </classpath> </bind>
        Hide
        Colin Sharples added a comment -

        You could just have said RTFM

        I didn't realise that the runtime jar needed to be explicitly in the classpath of the bind item. I had included in in the taskdef, and thought that would be enough, but obviously not. I guess I haven't read the documentation recently.

        Show
        Colin Sharples added a comment - You could just have said RTFM I didn't realise that the runtime jar needed to be explicitly in the classpath of the bind item. I had included in in the taskdef, and thought that would be enough, but obviously not. I guess I haven't read the documentation recently.
        Colin Sharples made changes -
        Field Original Value New Value
        Resolution Not A Bug [ 6 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Hide
        Dennis Sosnoski added a comment -

        This comes up regularly, so I'll take a look to see if I can build a workaround. It seems like I should be able to get the classpath used to load the jibx-run.jar classes and automatically add that to the classpath specified by the user.

        Show
        Dennis Sosnoski added a comment - This comes up regularly, so I'll take a look to see if I can build a workaround. It seems like I should be able to get the classpath used to load the jibx-run.jar classes and automatically add that to the classpath specified by the user.
        Dennis Sosnoski made changes -
        Resolution Not A Bug [ 6 ]
        Assignee Dennis Sosnoski [ dsosnoski ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Dennis Sosnoski made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]

          People

          • Assignee:
            Dennis Sosnoski
            Reporter:
            Colin Sharples
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: