Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:58:29+00:00 2026-06-09T20:58:29+00:00

I have a Maven-based project, in which I trying to add some JAXB classes

  • 0

I have a Maven-based project, in which I trying to add some JAXB classes automatically generated by the “jaxb2-maven-plugin” Maven plugin. However, my first cut has me in a circular dependency loop:

  • Because these JAXB classes aren’t generated yet, my other sources which reference them have compilation errors.
  • Because those other sources have compilation errors, these JAXB classes don’t get generated.

It seems like there are two obvious possibilities for solving this:

  1. Comment-out the broken references, so that the project builds and the JAXB classes are automatically generated. Then copy those generated sources from /target into /src/main/java, so that references to them won’t cause compilation errors.
  2. Create an entirely separate project, consisting of nothing but the JAXB stuff. Include it as a dependency in my main project.

Am I missing something here? Option #1 seems flat-out ridiculous… that just can’t be the manner in which people use JAXB. Option #2 seems more rational, but still rather inefficient and cumbersome. I really have to take on the overhead of an entirely separate project just to use JAXB?

Are there any more elegant approaches that developers use to reference JAXB-generated classes in the same project where the Maven plugin generates them?

UPDATE: By request, here is the relevant portion of my POM:

<build>
    <plugins>
        <plugin>
            <!-- configure the compiler to compile to Java 1.6 -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>       
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <!-- The name of your generated source package -->
                <packageName>com.mypackage</packageName> 
            </configuration>
        </plugin>
    </plugins>  
</build>

When I run mvn clean package, I DO see my JAXB sources being generated beneath the /target subdirectory. However, those generated sources are not being automatically added to the classpath for the compile phase.

POST-RESOLUTION UPDATE: It turns out that my compilation issues had more to do with the fact that I was running in Eclipse, and its Maven integration has some issues with “jaxb2-maven-plugin”. See this StackOverflow question for more detail on that issue and its resolution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:58:30+00:00Added an answer on June 9, 2026 at 8:58 pm

    i would suggest you to split jaxb-generated classes (api) and your BL classes (implementation) to 2 maven projects with separate pom.xml for each, and the main root pom.xml with the compilation order. that way, you will be able to build api.jar, then maven will install it inside the local repo, and after that you can use it as the dependency of your implementation. so it will looks like:

    -API\
    --pom.xml - for api, jaxb generation
    -IMPL\
    --pom.xml - for impl, api dependency is here
    pom.xml - main pom.xml with references to the projects above
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to instal sbt based project to local maven repository. I have tried
I do have a MAVEN based java project that requires some environment variables. So
I have two maven-based eclipse projects, one being a project with common classes and
I got following error when build maven datanucleus based project. I have placed maven-datanucleus-plugin
I have a Maven based Spring-WS client project that I want to package as
I have maven-plagin and need to run goal, that should automatically run before plugin.
I have a maven Java project (Project A) which depends on a second project
I have a Maven project which generates a 413.06 KB jar file. I have
I have a maven-based GWT project that includes Guava. I am running into trouble
I have a maven based mule project that was original created with mule version

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.