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

  • SEARCH
  • Home
  • 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 4015890
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:40:26+00:00 2026-05-20T09:40:26+00:00

The scenario is the following: I have a java package ( myapp.config ) that

  • 0

The scenario is the following: I have a java package (myapp.config) that contains all my JAXB-annotated classes, from which I’d like to generate an XML schema file. In the package, there is also a package-info.java file, which contains the @XmlSchema annotation on the package element, thus valid in the whole package:

@XmlSchema(namespace="http://myapp/config",
           xmlns = @XmlNs(prefix="myapp", namespaceURI="http://myapp/config"),
           elementFormDefault=XmlNsForm.QUALIFIED)
package myapp.config;

When I run the schemagen command-line tool that comes with the JDK,

D:\Projects\Myapp>"%JAVA_HOME%/bin/schemagen" -cp "%JAVA_HOME%/lib/tools.jar"
src/myapp/config/*.java

I get the correct result: the root element in the generated schema1.xsd file contains the targetNamespace and other necessary attributes:

<xs:schema elementFormDefault="qualified" version="1.0"
           targetNamespace="http://myapp/config"
           xmlns:tns="http://myapp/config"
           xmlns:myapp="http://myapp/config">
           xmlns:xs="http://www.w3.org/2001/XMLSchema" >

However, when I want to perform the same task within my Ant script,

<schemagen srcdir="src/myapp/config" destdir="dist">
    <include name="*.java"/>
</schemagen>

The schemagen tool seems to completely ignore the namespace annotations, because in the resulting schema1.xsd file, there is no trace of them:

<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

When I run the schemagen task in verbose and debug mode, it becomes obvious that the tool does load all the .java files, except package-info.java, that’s why it doesn’t know anything about the namespaces.

Have you met this strange behavior before? Why the command-line tool processes the package info file, and the Ant task doesn’t? What should I do to make the Ant task work?

Thanks in advance,
buc

  • 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-05-20T09:40:26+00:00Added an answer on May 20, 2026 at 9:40 am

    Fortunately I found the solution, I post it for those who run into the same problem in the future:

    The reason it did not work is that I called the schemagen task in the wrong way (this can happen, if there is so little documentation or examples as in the case of schemagen).
    Instead of writing:

    <schemagen srcdir="src/myapp/config" destdir="dist">
        <include name="*.java"/>
    </schemagen>
    

    You should move the specific part of the path into the include element:

    <schemagen srcdir="src" destdir="dist">
        <include name="myapp/config/*.java"/>
    </schemagen>
    

    I’m still not sure why this is happening, but this way, the schemagen processor recognizes that the myapp/config directory in fact designates the java package myapp.config and by knowing that it is a package, it will also read the package info file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following scenario (in Java / Hibernate): I have two entity classes:
The scenario is the following. I have a plain text file which contains 2,000,000
Consider following scenario: I have RESTful URL /articles that returns list of articles user
I have the following scenario: Entities are loaded from the database. One of them
Have the following scenario. I have a few form, which essentially have a few
I am rather noob at java jars deployment. I have following scenario: I have
Image the following scenario, You have 10 Java applications accessing a database server Each
I've the following scenario: I've a byte[] that contains the .class data of a
I have question about try, catch and finally in Java. Consider the following scenario:
Imagine following scenario: We have a lot of parallel development going on in several

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.