Error when using XmlBeans generated classes

后端 未结 5 2261
刺人心
刺人心 2021-02-20 09:43

I\'ve generated classes with XMLBeans from an xsd file and packed them in a jar file. then I\'ve added that jar to the project classpath in eclipse and everything compiles and r

相关标签:
5条回答
  • 2021-02-20 10:22

    Please add below tag in pom.xml. Error wil go

            <!--
                this tells maven to copy the openejb-javaagent jar into your target/
                directory
            -->
            <!-- where surefire can see it -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.openejb</groupId>
                                    <artifactId>openejb-javaagent</artifactId>
                                    <version>3.0-beta-2</version>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>target/generated-sources/axis2/wsdl2code/resources</directory>
            </resource>
            <resource>
                <directory>target/generated-sources/xmlbeans/resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
    </build>
    
    0 讨论(0)
  • 2021-02-20 10:25

    When you have this kind of error The TypeSystemHolder.class generated by WSDL2Java is not be placed in your classpath in order to avoid this error.

    Please copy TypeSystemHolder.class from "resource/schemaorg_apache_xmlbeans/system/s68C41DB812F52C975439BA10FE4FEE54" folder.

    And Paste TypeSystemHolder.class file into your classpath folder (build/classes/schemaorg_apache_xmlbeans/system/s68C41DB812F52C975439BA10FE4FEE54) folder

    0 讨论(0)
  • 2021-02-20 10:30

    In your generated jar file make sure you have included the class files generated from your xmlbeans.

    From the stacktrace :

    Caused by: java.lang.ClassNotFoundException: schemaorg_apache_xmlbeans.system.s8
    B21CFFFCFED0B2438C2585C61F113F7.TypeSystemHolder
    

    it suggests that during compile time the required class files are in classpath but in your built jar these files are missing.

    Check your jar file to see if these classes are present.

    EDIT: As per question rephrased

    For building jar with dependecies in Maven use jar-with-dependencies option, example

    Two very good reference :

    1. http://www.sonatype.com/books/mvnref-book/reference/assemblies-sect-basics.html

    2. http://thomassundberg.wordpress.com/2011/03/05/create-an-executable-jar-from-maven/

    In the second one you don't need a main class if your jar is not an executable jar

    0 讨论(0)
  • 2021-02-20 10:38

    While doing WSDL2Java a directory named resources will be created. Copy the schemaorg_apache_xmlbeans which presents under resources to classpath of your project. This should be the fix.

    0 讨论(0)
  • 2021-02-20 10:47

    Extract jar in which you want to include schemaorg_apache_xmlbeans folder. Copy schemaorg_apache_xmlbeans folder in extracted folder (result from jar extraction). open command prompt in extracted folder.

    make jar again using jar cf command. e.g jar cf test.jar *, to include all folders.

    Deploy that jar .

    0 讨论(0)
提交回复
热议问题