You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Jacob Barde <ja...@swri.org> on 2009/08/05 21:42:11 UTC

Re: Maven and XMLBeans, not best friends??

hannehomuth,

Might want to try a more recent version of the mojo xmlbeans plugin.  
It's currently up to version 2.3.2, and it supports XMLBeans 2.4.0, 
located on http://repository.codehaus.org/.

I use the following to generate source and compiled jars with success.  
One thing though, if you don't clean after a previous package command, 
the -sources.jar file won't be generated correctly.

Good luck,

Jay


//pom.xml BEGIN
<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/maven-v4_0_0.xsd">
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.3.2</version>
                <executions>
                    <execution>
                        <id />
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xmlbeans-maven-plugin</artifactId>
                <version>2.3.2</version>
                <executions>
                    <execution>
                        <id />
                        <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.5</javaSource>
                    <!-- use this only if your schemata are nested in 
child folders, or are in a folder other than `src/main/xsd'
                    <sourceSchemas>
                        <sourceSchema>bar/foo.xsd</sourceSchema>
                        <sourceSchema>foo/bar.xsd</sourceSchema>
                    </sourceSchemas>
                    -->
                    <!-- again, use this only if your xsdconfig files 
are nested in child folders, or are in a folder other than 
`src/main/xsdconfig'
                    <xmlConfigs>
                        <xmlConfig 
implementation="java.io.File">src/main/xsd/bar/foo.xsdconfig</xmlConfig>
                        <xmlConfig 
implementation="java.io.File">src/main/xsd/foo/bar.xsdconfig</xmlConfig>
                    </xmlConfigs>
                    -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xmlbeans-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id />
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xmlbeans-test</goal>
                        </goals>
                    </execution>
                </executions>
                <inherited>true</inherited>
                <configuration>
                    <schemaDirectory>src/test/xsd</schemaDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans-qname</artifactId>
            <version>2.4.0</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans-xmlpublic</artifactId>
            <version>2.4.0</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jsr173_api</artifactId>
            <version>1.0</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>xml-resolver</groupId>
            <artifactId>xml-resolver</artifactId>
            <version>1.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>
//pom.xml END


hannehomuth wrote:
> Hi to everyone,
>
> I've trying and searching a lot of hours but could not find any solution
> which worked for me.
>
> I want to use xmlbeans in an project which uses maven as build tool. I've
> configured the plugin in the pom.xml in this way
>
> <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>xmlbeans-maven-plugin</artifactId>
>                 <version>2.1.0</version>
>                 <executions>
>                     <execution>
>                         <id>Build-XMLBeans</id>                       
>                         <goals>
>                             <goal>xmlbeans</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>                 <configuration>
>                    
> <schemaDirectory>src/main/java/com/vw/ais/jobengine/propertytypes</schemaDirectory>
>                    
> <schemaDirectory>src/main/java/com/vw/ais/jobengine/configurations</schemaDirectory>
>                    
> <classGenerationDirectory>${project.build.directory}/generated-classes/xmlbeans</classGenerationDirectory>
>                    
> <sourceGenerationDirectory>${project.build.directory}/generated-sources/xmlbeans</sourceGenerationDirectory>                    
>                     <verbose>true</verbose>
>                 </configuration>
>             </plugin>
>
> Furthermore I have declared some dependencies for xmlbeans
>
>  <dependencies>
>         <dependency>
>             <groupId>xmlbeans</groupId>
>             <artifactId>xmlbeans</artifactId>
>             <version>2.2.0</version>
>         </dependency>       
>         <dependency>
>             <groupId>xmlbeans</groupId>
>             <artifactId>xbean</artifactId>
>             <version>2.1.0</version>
>         </dependency>                
>     </dependencies>
>
> The project build will run successful, but when I try to run the app, I get
> the good old 
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
>         at
> com.vw.ais.jobengine.validation.ConfigurationValidator.schematicValidation(ConfigurationValidator.java:98)
>         at
> com.vw.ais.jobengine.validation.ConfigurationValidator.validate(ConfigurationValidator.java:58)
>         at com.vw.ais.jobengine.JobEngine.initialize(JobEngine.java:54)
>         at com.vw.ais.jobengine.Test.main(Test.java:34)
> Caused by: java.lang.RuntimeException: Cannot load SchemaTypeSystem. Unable
> to load class with name
> schemaorg_apache_xmlbeans.system.s09447651F54C8102642F6478AB9428E3.TypeSystemHolder.
> Make sure the generated binary files are on the classpath.
>         at
> org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:783)
>         at
> com.vw.ais.jobengine.configurations.JobEngineDocument.<clinit>(JobEngineDocument.java:19)
>         ... 4 more
> Caused by: java.lang.ClassNotFoundException:
> schemaorg_apache_xmlbeans.system.s09447651F54C8102642F6478AB9428E3.TypeSystemHolder
> .......
> .......
>
> The Class
> schemaorg_apache_xmlbeans.system.s09447651F54C8102642F6478AB9428E3.TypeSystemHolder
> lies in the jar. 
>
> What the hell is wrong here. Does anyone see what I'm doing wrong here.
> Thx for suggestions
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Maven and XMLBeans, not best friends??

Posted by Andreas Loew <An...@Sun.COM>.
Jacob Barde schrieb:

> Might want to try a more recent version of the mojo xmlbeans plugin.  
> It's currently up to version 2.3.2, and it supports XMLBeans 2.4.0, 
> located on http://repository.codehaus.org/.

... and - just in case - please be aware of the fact that you still have 
the full freedom/flexibility to fall back to using the 
maven-antrun-plugin and "good old" XMLBeans Ant tasks... ;-)

-- 
Andreas Loew
Senior Java Architect
Sun Microsystems (Germany)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org