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 8842493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:58:20+00:00 2026-06-14T10:58:20+00:00

I tried to generate Jaxb Classes from XSD using jaxb2-maven-plugin. I am able to

  • 0

I tried to generate Jaxb Classes from XSD using jaxb2-maven-plugin.

I am able to get the jaxb classes in a package but my other packages are getting deleted. What is the reason for this? How to over come this? please can you give suggestions.

Below is what I tried

<bulid>
    <pluginManagement>
    <plugins>
        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>xjc</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <schemaDirectory>src/main/xsd</schemaDirectory>
            <outputDirectory>src/main/java</outputDirectory>
        </configuration>
        </plugin>
    </plugins>
    </pluginManagement>
    </bulid>

and xsd look like this :

<?xml version="1.0" encoding="UTF-8"?><xsd:schema targetNamespace="com.test.jaxb.model" 
        xmlns:ns="com.test.jaxb.model" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="TestResults">
        <xsd:sequence>
            <xsd:element maxOccurs="unbounded" minOccurs="0" name="testSuites" type="Q1:TestSuiteRun"/>
        </xsd:sequence>
        <xsd:attribute name="testProject" type="xsd:string"/>
    </xsd:complexType>


    <xsd:complexType name="TestCaseRun">
        <xsd:complexContent>
            <xsd:extension base="Q1:TestRun">
                <xsd:sequence>
        <xsd:element name="result" type="Q1:Severity"/>
      <xsd:element maxOccurs="unbounded" minOccurs="0" name="variations" type="Q1:VariationRun">
                    </xsd:element>
                </xsd:sequence>
                <xsd:attribute name="variationCount" type="xsd:int"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    </xsd:schema>

I have given targetNamespace=”com.test.jaxb.model” but after generation I am only able to see jaxb classes under package name : model.jaxb.test.com..

Why so the package name is geting reversed and why is my other packages getting deleted ?

  • 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-14T10:58:21+00:00Added an answer on June 14, 2026 at 10:58 am

    Your main problem is that you are using the src/main/java as <outputDirectory>. There are two major problems with that.

    1. The generated sources will be in a directory structure that under normal circumstances is under version control. What will you do with the generated sources? Should they be checked in? Your VCS will be signalling that new files have been found that are still not added.
    2. The generated sources will not be deleted when you call mvn clean.

    You should remove the <outputDirectory>src/main/java</outputDirectory> completely and let maven and the plugin to their job.

    If you remove those lines you will have the sources generated into target/generated-sources and they will be compiled during the compile phase which I assume is what you want.


    Regarding the reversed package name I believe you should change targetNamespace to this:

    <xsd:schema targetNamespace="http://www.test.com/jaxb/model"
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am not able see any of jaxb classes generated from my xsd using jaxb2-maven-plugin
I tried using axis2 1.6 (and nightly 1.7) to generate Java code from the
I need to generate a lot of random numbers. I've tried using random.random but
I'm using jaxb to generate java object class from xml schemas within an Ant
I wamt to generate xml from java class using JAXB from a bean class,please
Just tried to generate java client generation from a WSDL file ( using XFire
I use maven 3.0.3 and have tried to generate pom for third-party jar like
I've tried some tools for generate automatically class diagrams from the java source code
I want to generate fixtures from the development database in Rails 3.1. I tried
tried uncommenting pam_limits.so from the pam.d directory but no luck. Basic PAM seems to

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.