Skip to main content



      Home
Home » Newcomers » Newcomers » Maven JAXB Generated Classes not in Eclipse Classpath
Maven JAXB Generated Classes not in Eclipse Classpath [message #646994] Mon, 03 January 2011 17:12 Go to next message
Eclipse UserFriend
Hi,

I'm using the maven-jaxb2-plugin from org.jvnet.jaxb2.maven2 to generate model objects. The plugin successfully parses my XSD, generates the Java Source (in target/generated-sources/xjc), compiles, and packages the class files in a JAR file.

Using just Maven, the project builds fine. Maven knows about the generated classes.

However in Eclipse (using the Sonatype Maven integration plugin), the generated classes aren't in the Eclipse classpath. Eclipse reds the generated class imports.

I had to edit the Eclipse classpath to include target/generated-sources/xjc so Eclipse resolves generated classes, but I do not think its a good idea to put target directories in the classpath.

How do I get Eclipse to recognize the generated classes?

Here is my POM:
      <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <executions>            
          <execution>                   
            <id>sitemap</id>                    
            <goals>                             
              <goal>generate</goal>                     
            </goals>                            

            <configuration>                     
              <schemaDirectory>${basedir}/source/main/resources</schemaDirectory>
              <localRepository></localRepository>       
              <schemaIncludes>                          
                <include>app.configuration.xsd</include>        
              </schemaIncludes>                         
              <args>                                    
                <param>-npa</param>                             
              </args>                                   
              <npa>true</npa>                           
              <removeOldOutput>true</removeOldOutput>   
              <verbose>false</verbose>                  
            </configuration>                    
          </execution>                  
        </executions>           
      </plugin>  
Re: Maven JAXB Generated Classes not in Eclipse Classpath [message #673778 is a reply to message #646994] Tue, 24 May 2011 13:43 Go to previous messageGo to next message
Eclipse UserFriend
What I did to solve this problem was to add target/generated-sources/xjc as a Source directory in the Eclipse project's Java Build Path (not Eclipse's classpath). I'm not sure this is ideal, but it works.

If anyone has a better solution, please post.
Re: Maven JAXB Generated Classes not in Eclipse Classpath [message #726836 is a reply to message #673778] Mon, 19 September 2011 12:40 Go to previous messageGo to next message
Eclipse UserFriend
Anyone have a better solution for Eclipse? I took the same approach of adding target/generated-sources/xjc to the java build path. But after doing a clean, Eclipse can't build because it is missing a source directory.
Re: Maven JAXB Generated Classes not in Eclipse Classpath [message #729495 is a reply to message #726836] Mon, 26 September 2011 06:29 Go to previous messageGo to next message
Eclipse UserFriend
In command line:
1. mvn eclipse:clean
2. mvn eclipse:eclispe
In eclipse:
1. refresh your project (click rmb and choose refresh)
(optionaly clean project)
Done

Regards
Re: Maven JAXB Generated Classes not in Eclipse Classpath [message #1391042 is a reply to message #729495] Mon, 30 June 2014 07:14 Go to previous message
Eclipse UserFriend
Thanks Karol. Your solution worked like magic.
Previous Topic:Eclipse EGit pushing latest commit hangs plink.exe
Next Topic:IBM WebSphere8.0 Application Server
Goto Forum:
  


Current Time: Tue Jun 24 19:47:23 EDT 2025

Powered by FUDForum. Page generated in 0.06911 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top