Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I wanted to compare how JiBX stacks against JAXB in terms of performance. From their website, they claim "It also provides very high performance, outperforming all other Java data binding tools across a wide variety of tests.". This sounded great, especially since I've identified that JAXB is a bottleneck. I downloaded JiBX 1.2.6 and proceeded to generate my bindings, only to find that it could not handle my schema.

The error I kept on getting was java.lang.IllegalStateException: Internal error - type definition not found. With verbose output enabled, this is what JiBX CodeGen output...
 JiBX Binding Generation
Output to directory generated
Loaded and validated 1 specified schema(s) and 6 referenced schema(s):
top-level schema CDA-AU-V1_0.xsd
referenced schema POCD_MT000040-AU-V1_0.xsd
referenced schema datatypes-V3_0.xsd
referenced schema datatypes-base-V3_0.xsd
referenced schema voc-V3_0.xsd
referenced schema NarrativeBlock.xsd
referenced schema EXTENSION.xsd
Exception in thread "main" java.lang.IllegalStateException: Internal error - type definition not found
at org.jibx.schema.codegen.custom.ComponentExtension.replaceAndReference(ComponentExtension.java:393)
at org.jibx.schema.codegen.custom.ComponentExtension.applyAndCountUsage(ComponentExtension.java:612)
at org.jibx.schema.codegen.custom.ComponentExtension.applyAndCountUsage(ComponentExtension.java:723)
at org.jibx.schema.codegen.CodeGen.processExtensions(CodeGen.java:435)
at org.jibx.schema.codegen.CodeGen.applyAndNormalize(CodeGen.java:459)
at org.jibx.schema.codegen.CodeGen.generate(CodeGen.java:1733)
at org.jibx.schema.codegen.CodeGen.main(CodeGen.java:2206)

After some research, I found a post that pretty much described the issue that I was seeing. Unfortunately I could not find any ways around this without having to spend a significant effort to modify the schema.

Expanding on the post I found, this is what the schema layout looks like (arrows show import or include). I created this image using twopi and dotty tools from Graph Viz.

The circular dependencies are quite clear.

The only schema that I could successfully generate bindings for was NarrativeBlock.xsd, this is because it's a leaf node in the overall schema layout without any other includes/imports. Every single other XSD failed with the same exception.

It's a shame that JiBX can't handle this kind of schema layout, but then the HL7/CDA schema is not the best example of good schema design either.


A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.