java 来自 xmlbeans 的 RuntimeException - 找不到已编译的架构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1180776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
RuntimeException from xmlbeans - can't find compiled schema
提问by findango
I'm getting a RuntimeException while executing some code that depends on generated xmlbeans classes. I can't figure out if this is:
我在执行一些依赖于生成的 xmlbeans 类的代码时遇到 RuntimeException。我不知道这是不是:
- 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?
xbean.jar 版本在构建和执行环境中是相同的。任何人以前见过这个或有任何想法?
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...
回答by J?rg Müller
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.
约翰的回答对我来说是一个很好的提示。我使用 xmlBeans 生成了 Java 类,并在我的项目中手动从“noNamespace”中复制了源文件以修改它们。不幸的是,我没有意识到“schemaorg_apache_xmlbeans”文件夹中也有生成的类文件并且没有复制它们。
切换到使用生成的 jar 文件后,一切对我来说都很好。
回答by Ian
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)...
我以前从未使用过图书馆,但我可以猜测发生了什么。有了那个预选赛(即,我只是在编造这个,但已经过去了 7 个小时,没有其他人编造任何东西)......
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.
说明很明显:某些东西已在某处编译,无法加载。我不认为这个东西在 jar 文件中;我猜这是您的资源之一,已编译/缓存到某个位置。
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 .`
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?
你能在类/资源上做一个 md5 导致编译和运行时环境出现问题吗?他们匹配吗?
Hope something in there helps or triggers a thought.
希望里面的东西能帮助或引发一个想法。
回答by John Meagher
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.
当有一个脚本(ant、maven、...)可以处理 XMLBeans 编译并且使用另一种机制来编译和运行其余代码时,我经常看到这个问题。有时,一个片段会删除 XMLBeans 在堆栈跟踪中查找的生成文件,但会保留生成的 XMLBeans Java 文件,因此所有内容都可以编译并且看起来不错。
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.
我在使用选项输出源文件而不是类文件时也看到了这一点。非Java源文件只直接生成到XMLBeans生成的class文件夹或jar文件中。
回答by anon
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.
这些类文件在 resources/schemaorg_apache_xmlbeans 目录中生成。我已经看到 xmlbeans 行为,其中生成的 ant 脚本未能将此目录包含在它创建的 jar 中(可能是由于错误?)检查它是否已包含在 jar 中。您可以手动重新 jar,或检查您的代码生成命令行选项。

