首页 > 解决方案 > 包含的 XMLBeans .jar 文件使用了错误的 schemaorg_apache_xmlbeans.system.HASH

问题描述

我有两个基于 Intellij Maven 的项目。第一个是使用 xmlbeans 将一堆 .XSD 文件转换为类的库。第二个是导入库并使用 xmlbean 生成的类的项目。第一个项目生成类是'schemaorg_apache_xmlbeans/system/sB743BF26396730AECDBC120E2F8D4B9A ...',但第二个错误是'Caused by:java.lang.RuntimeException:无法加载SchemaTypeSystem。无法加载名为 schemaorg_apache_xmlbeans.system.s5EFEB9AF80B80B5F805AFE83A6ADE419.TypeSystemHolder 的类。确保生成的二进制文件位于类路径中。

显然 xmlbean 系统哈希是不同的,不知道第二个项目的来源

该库在我不使用 Maven 时工作,我将项目 (cut-n-paste) 重建为一个新的 Maven 项目,因为我试图将所有内容都转换为 Maven。

项目 1(库)基于 Maven,我看到生成的 .jar 文件已安装到我的 .m2 本地存储库中。存储库 .jar 具有 sB743BF26396730AECDBC120E2F8D4B9A 的 xmlbeans 哈希

项目 2(应用程序)是基于 Maven 的,我有项目 1 jar 文件的依赖项

项目 1(库):Maven pom.xml


    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <groupId>com.crocker.integrations</groupId>
        <artifactId>broadworks</artifactId>
        <version>1.0.1</version>
      <build>
            <resources>
                <resource>
                    <directory>target/generated-classes/xmlbeans</directory>
                    <includes>
                        <include>**/*.*</include>
                    </includes>
                </resource>
            </resources>

    [...]

               <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>xmlbeans-maven-plugin</artifactId>
                    <version>2.3.3</version>
                    <executions>
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>xmlbeans</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <schemaDirectory>src/main/xsd</schemaDirectory>
                        <staleFile>${project.build.directory}/generated-sources/xmlbeans/.staleFlag</staleFile>
                        <verbose>false</verbose>
                        <quiet>false</quiet>
                        <javaSource>1.6</javaSource>
                    </configuration>
                </plugin>
    ```

    Project 2 (the application):
    ```xml
    <dependencies>
            <dependency>
                <groupId>com.crocker.integrations</groupId>
                <artifactId>broadworks</artifactId>
                <version>1.0.1</version>
            </dependency>
    ```


    all of the objects resolve in intellij,  compiles clean,  runs and then barfs when trying to pull up the xmlbean.

    It is clear in the error below that the hashes are different and that is why the runtime can't find the object.   I've cleaned and rebuilt all of the project repeatedly and cannot for the life of me figure out why Project 2 gets the wrong hash.

    Exception in thread "main" java.lang.ExceptionInInitializerError
        at webservice.broadsoft.com.ProcessOCIMessageDocument$Factory.newInstance(ProcessOCIMessageDocument.java:92)
        at com.crocker.integrations.broadworks.OCIASSession.processOCICommand(OCIASSession.java:78)
        at com.crocker.integrations.broadworks.OCIASSession.Authenticate(OCIASSession.java:106)
        at com.crocker.integrations.broadworks.Broadworks.login(Broadworks.java:23)
        at com.crocker.projects.App.main(App.java:42)
    Caused by: java.lang.RuntimeException: Cannot load SchemaTypeSystem. Unable to load class with name schemaorg_apache_xmlbeans.system.s5EFEB9AF80B80B5F805AFE83A6ADE419.TypeSystemHolder. Make sure the generated binary files are on the classpath.
        at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:788)
        at webservice.broadsoft.com.ProcessOCIMessageDocument.<clinit>(ProcessOCIMessageDocument.java:20)
        ... 5 more
    Caused by: java.lang.ClassNotFoundException: schemaorg_apache_xmlbeans.system.s5EFEB9AF80B80B5F805AFE83A6ADE419.TypeSystemHolder
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:774)
        ... 6 more

    Process finished with exit code 1

标签: javamavenintellij-ideaxmlbeans

解决方案


推荐阅读