Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
Ryan S. is currently offline Ryan S.
Messages: 1
Registered: January 2011
Junior Member
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 User is currently offline Eclipse User
Messages: 1
Registered: May 2011
Junior Member
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
pansonm is currently offline pansonm
Messages: 1
Registered: September 2011
Junior Member
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
Karol  r is currently offline Karol r
Messages: 1
Registered: September 2011
Junior Member
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
Amit Nimbhorkar is currently offline Amit Nimbhorkar
Messages: 1
Registered: June 2014
Junior Member
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 Jul 29 23:06:34 EDT 2014

Powered by FUDForum. Page generated in 0.02060 seconds