Reputation: 69349
I use the XMLBeans Maven plugin to generate classes based on an XSD file. I am able to write code using my generated classes and Eclipse shows target/generated-sources/xmlbeans
as a source folder. However, when I try to run my test code I get the classic error:
java.lang.ClassNotFoundException: schemaorg_apache_xmlbeans.system.sCFA0DE5D65ADE16E20A85EAFD5A886E4.TypeSystemHolder
If I look in my project folder, I can see this class file in the folder target\generated-classes\xmlbeans\schemaorg_apache_xmlbeans\system\sCFA0DE5D65ADE16E20A85EAFD5A886E4
.
Is there a change I can make to my POM file to make Eclipse know where to find these classes? I imagine there are a number of ways to manually fix this problem and tell Eclipse to add that folder to the classpath, but I'd prefer an automatic solution.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<inherited>true</inherited>
<configuration>
<schemaDirectory>src/main/xsd</schemaDirectory>
<download>true</download>
<javaSource>1.5</javaSource>
</configuration>
</plugin>
Upvotes: 3
Views: 4550
Reputation: 9816
Found a working solution for me - these guys wrote a maven connector. So you basically just have to install the XMLBeans connector from here.
Upvotes: 1
Reputation: 14951
I have used this to incorporate generated code. Make sure to bind the plugin to a phase after the code generation happens, or if using the same phase, that this plugin configuration appears after the xmlbeans-maven-plugin
configuration.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build.helper.maven.plugin.version}</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${xmlbeans.sourceGenerationDirectory}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 2