tags:

views:

731

answers:

3

I'm getting a RuntimeException while executing some code that depends on generated xmlbeans classes. I can't figure out if this is:

  • me missing something during code-generation or packaging
  • a runtime dependency missing
  • a misleading error message, and I should be looking elsewhere.

The xbean.jar version is the same in the build and execution environment. Anyone seen this before or have any ideas?

Thanks.

...snip...
Caused by: java.lang.RuntimeException: Could not instantiate SchemaTypeSystemImpl (java.lang.reflect.InvocationTargetException): is the version of xbean.jar correct?
    at schemaorg_apache_xmlbeans.system.s2B8331230CBD98F4933B0B025B6BF726.TypeSystemHolder.loadTypeSystem(Unknown Source)
    at schemaorg_apache_xmlbeans.system.s2B8331230CBD98F4933B0B025B6BF726.TypeSystemHolder.(Unknown Source)
    ... 38 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    ... 40 more
Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/s2B8331230CBD98F4933B0B025B6BF726/index.xsb (schemaorg_apache_xmlbeans.system.s2B8331230CBD98F4933B0B025B6BF726.index) - code 0
    at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.(SchemaTypeSystemImpl.java:1504)
    at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.initFromHeader(SchemaTypeSystemImpl.java:260)
    at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.(SchemaTypeSystemImpl.java:183)
    ... 44 more
...snip...
A: 
Ian
A: 

I have seen this problem often when there was a script (ant, maven, ...) that would handle the XMLBeans compilation and another mechanism was used for compiling and running the rest of the code. Sometimes one piece will delete the generated files that XMLBeans is looking for in your stack trace, but will leave the generated XMLBeans Java files so everything will compile and look fine.

I have also seen this when using the option to output the source files, but not the class files. The non-Java source files are only generated directly into the class folder or jar file generated by XMLBeans.

John Meagher
A: 

These class files are generated in the resources/schemaorg_apache_xmlbeans directory. I have seen xmlbeans behaviour where the generated ant script has failed to include this directory in the jar it creates (perhaps due to a bug?) Check that it has been included in the jar. You could manually re-jar, or check your code generation commandline options.

anon