JiBX

ArrayIndexOutOfBoundsException by precomiled include with single mapping element

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: JiBX 1.2.2
  • Fix Version/s: None
  • Component/s: BindGen
  • Labels:
    None
  • Environment:
    Windows Vista
  • Number of attachments :
    1

Description

Dear experts,

I ran into and debugged the following problem:

I use precomiled include in binding configuration. In the included binding is only one abstract mapping declaration. In this case, jibx throws the following exception:

[INFO] Running JiBX binding compiler (single-module mode) on 1 binding file(s)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] 0

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: 0
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: 0
at org.jibx.maven.CompileBindingMojo.compile(CompileBindingMojo.java:224)
at org.jibx.maven.CompileBindingMojo.execute(CompileBindingMojo.java:173)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.jibx.binding.def.BindingBuilder.unmarshalPrecompiledMappings(BindingBuilder.java:1999)
at org.jibx.binding.def.BindingBuilder.unmarshalInclude(BindingBuilder.java:2092)
at org.jibx.binding.def.BindingBuilder.unmarshalBindingDefinition(BindingBuilder.java:2165)
at org.jibx.binding.Utility.loadBinding(Utility.java:319)
at org.jibx.binding.Utility.loadFileBinding(Utility.java:439)
at org.jibx.binding.Compile.compile(Compile.java:217)
at org.jibx.maven.CompileBindingMojo.compile(CompileBindingMojo.java:221)
... 19 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Fri Aug 27 11:04:56 CEST 2010
[INFO] Final Memory: 20M/127M
[INFO] ------------------------------------------------------------------------

If the included binding contains more than one mapping declaration, everything works fine.

Included binding:
<binding name="common_binding" package="de.unioninvestment.osiris.marktdepot.soa.objectmodel.control">
<!-- custom format -->
<format type="java.math.BigDecimal" serializer="de.unioninvestment.osiris.marktdepot.soa.objectmodel.util.DateFormatUtils.serializeDateTime"
deserializer="de.unioninvestment.osiris.marktdepot.soa.objectmodel.util.DateFormatUtils.deserializeDateTime" label="daskaDateFormat"/>

<mapping abstract="true" type-name="Zeitraum" class="de.unioninvestment.osiris.marktdepot.soa.objectmodel.control.Zeitraum">
<value style="element" name="DatumVon" get-method="getDatumVon" set-method="setDatumVon" usage="optional" format="daskaDateFormat"/>
<value style="element" name="DatumBis" get-method="getDatumBis" set-method="setDatumBis" usage="optional" format="daskaDateFormat"/>
</mapping>

</binding>

Including binding:
<binding name="kunde_binding" package="de.unioninvestment.osiris.marktdepot.soa.objectmodel.business">

<include path="classpath:common-binding.xml" precompiled="true" />

<mapping abstract="true" type-name="Kunde" class="de.unioninvestment.osiris.marktdepot.soa.objectmodel.business.Kunde">
<value style="element" name="KundenNr" get-method="getKundenNr" set-method="setKundenNr" usage="optional"/>
</mapping>

</binding>

The cause is split handling for marsh and umarsh.
mars and unmars are arrays[0], BindingBuilder tries to access mars[0] and umars[0] --> Exception.

The generated jibx-factory for common_binding looks like this:
...
public class JiBX_common_bindingFactory extends BindingFactoryBase
implements IBindingFactory
{

private JiBX_common_bindingFactory()
{
super("common_binding", 0, 0, getClassList(), "de.unioninvestment.osiris.marktdepot.soa.objectmodel.control.Zeitraum", "", "", new String[] { "", "http://www.w3.org/XML/1998/namespace", "http://www.w3.org/2001/XMLSchema-instance" }, new String[] { "", "xml", "xsi" }, "Zeitraum", "\001", null, "de.unioninvestment.osiris.marktdepot.soa.objectmodel.control.Zeitraum|.......|.......Zeitraum.JiBX_common_binding_newinstance_1_0||||||........JiBX_common_binding_test_1_0|........JiBX_common_binding_unmarshal_1_0|........JiBX_common_binding_marshal_1_0", "\001", "", "", "", new String[0]);
}
...

The sixth and seventh arguments are unmarshaler and marshaler class names.

BindingFactoryBase is super class of the generated jibx factory.

In lines BindingFactoryBase (lines 120-133) handels marshaler names as followes:

120 if (marnames == null) { 121 m_marshallers = null; 122 m_marshallerClasses = new Class[0]; 123 } else { 124 m_marshallers = RuntimeSupport.splitClassNames(marnames); 125 m_marshallerClasses = new Class[m_marshallers.length]; 126 }
...

marnames is the seventh argument = ""
In line 124 m_marshallers is set to array[0]
In line 125 m_marshallerClasses is set to array[0].
BindingBuilder maps m_marshallerClasses to mars ==> mars is array[0] ==> Exception in line 1999

If the included binding contains two mappings, then
marnames = "|"
In line 124 m_marshallers is set to array[2]
In line 125 m_marshallerClasses is set to array[2].
BindingBuilder maps m_marshallerClasses to mars ==> mars is array[2] ==> everything works fine

Greeting,
Alex

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: