RuntimeException from xmlbeans - can't find compiled schema
Asked Answered
G

4

11

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...
Grew answered 25/7, 2009 at 0:19 Comment(0)
H
1

The answer of John was a good hint for me. I generated Java classes with xmlBeans and copied the source files out of the "noNamespace" manually in my project to modify them. unfortunately I did not recognize that there were also generated class files in the "schemaorg_apache_xmlbeans" folder and did not copy them.
After switching to the usage of the generated jar-file everything worked fine for me.

Hellcat answered 31/1, 2012 at 17:2 Comment(1)
I used wsdltojava to create some soap code. I didn't notice it also created a "resources" folder that I didn't copy into my project.Gyp
T
0

I've never used the library before but I can kind of guess at what's going on. With that qualifier (i.e., I'm just making this up, but it's been 7 hours and no one else has made anything up)...

Stating the obvious: something has been compiled somewhere and can't be loaded. I don't think this something is in the jar file; I'm guessing it's one of your resources that's been compiled/cached to some location.

I would guess either:

  • it's compiled in a place it's not loadable from (messed up classpath/config)
  • the versioning is wrong between what's been compiled and what wants to be loaded

Did you change something (e.g. schema version?) between the compilation and loading/running?

Can you remove the compiled version and recompile and then try a reload?

Can you locate the compiled version in the file system?

To do this, you might try

grep "s2B8331230CBD98F4933B0B025B6BF726" `find .`

from some suitable directory.

Can you do an an md5 on the class/resource causing problems in both compile and runtime environments? Do they match?

Hope something in there helps or triggers a thought.

Theodicy answered 25/7, 2009 at 8:20 Comment(0)
B
0

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.

Broads answered 28/7, 2009 at 1:59 Comment(0)
R
0

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.

Ripleigh answered 9/7, 2010 at 9:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.