XMLBeans更改默认生成的.xsb文件位置

时间:2018-11-07 22:13:00

标签: java xmlbeans jlink

好的,所以我有一个使用XMLBeans 3.0的主应用程序。我正在尝试使用Java10和Jlink创建一个自包含的JVM。因此,我使用scomp命令基于一些XSD文件生成Java类,并将其命名为custom.jar。 我打开custom.jar并注意到scomp将.xsb文件放在此程序包下:

 schemaorg_apache_xmlbeans.system.s2CA052CB375796887D9B5CB20D4C89AC

现在,我的JLink项目也依赖于xbean.jar。而且似乎该JAR也有一个类似于custom.jar的软件包:

schemaorg_apache_xmlbeans.system

因此,我编译主项目并使用JLink创建JVM运行时映像。这样我就可以提出我的申请了。
问题是,在运行时,我的应用程序引用了我的custom.jar中的类,但出现了文件丢失错误。 查看堆栈跟踪信息,似乎类加载器正在尝试在xbean.jar下找到我的自定义.xsb文件,但当然该JAR上不存在该文件。

我不太熟悉类加载的工作原理,尤其是现在在Java10 /模块中,但是没有人知道解决此问题的方法吗?

这些是来自模块信息xbean.jar的有关该软件包路径的导出:

exports schemaorg_apache_xmlbeans.system.sXMLCONFIG;
exports schemaorg_apache_xmlbeans.system.sXMLLANG;
exports schemaorg_apache_xmlbeans.system.sXMLSCHEMA;
exports schemaorg_apache_xmlbeans.system.sXMLTOOLS;

这些是我的custom.jar的出口,用于类似的包路径:

exports schemaorg_apache_xmlbeans.system.s2CA052CB375796887D9B5CB20D4C89AC;

下面是堆栈跟踪,但查看xbean.jar源代码,这是找不到.xsb文件的行:

SchemaTypeSystemImpl.this._resourceLoader.getResourceAsStream(resourcename);

也许是对任何模块信息文件的修改,或者如何告诉scomp更改默认的schemaorg_apache_xmlbeans.system包?

谢谢。

        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.RuntimeException: Could not instantiate SchemaTypeSystemImpl (java.lang.reflect.InvocationTargetException): is the version of xbean.jar correct?
        at custom/schemaorg_apache_xmlbeans.system.sD4E93FD3AF9AB0042ABA3EB739A1C5B8.TypeSystemHolder.loadTypeSystem(Unknown Source)
        at custom/schemaorg_apache_xmlbeans.system.sD4E93FD3AF9AB0042ABA3EB739A1C5B8.TypeSystemHolder.<clinit>(Unknown Source)
        ... 48 more
Caused by: java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
        ... 50 more
Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could not locate compiled schema resource schemaorg_apache_xmlbeans/system/sD4E93FD3AF9AB0042ABA3EB739A1C5B8/index.xsb (schemaorg_apache_xmlbeans.system.sD4E93FD3AF9AB0042ABA3EB739A1C5B8.index) - code 0
        at xbean/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.<init>(SchemaTypeSystemImpl.java:1519)
        at xbean/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.initFromHeader(SchemaTypeSystemImpl.java:273)
        at xbean/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:185)
        ... 54 more

0 个答案:

没有答案