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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:07:15+00:00 2026-05-25T13:07:15+00:00

Currently I’m busy on a project using XML messaging. I have one general schema,

  • 0

Currently I’m busy on a project using XML messaging. I have one general schema, with abstract types and some reusable type definitions and elements. For each sort of message I’m dealing with, there’s a separate schema (with a different target namespace) that imports the general one. In other words, it’s a two-level hierarchy. Pretty simple.

Each of these schemas is used for generating Java classes. Each schema corresponds to one package. The code generation is handled by the Maven JAXB 2.1 plugin. When I’m using the code, I create a separate JAXBContext for each message type. The JAXBContext is created using the package name of the general schema and that of the specific message type, so the context should only see those classes it has to deal with.

To my surprise I noticed that when I unmarshal an XML document to beans and then marshal those back to XML, there were namespace declarations for each and every message type (= schema target namespace). Wondering how JAXB got that info despite the context scope, I found out some @XmlSeeAlso annotations were placed on some abstract class definitions. This causes JAXB to seek information regarding classes outside of the target packages.

Is there any way to avoid generating the @XmlSeeAlso annotations? Looking around here, I found out this was new for JAXB 2.1. I could switch to an XJC plugin for 2.0, but I’m not certain if this would have unwanted side effects. Plus, I’d like to keep following new JAXB releases in the future. The unrequired namespace declarations are not a problem (the XML is still valid) but will be confusing once more message types are added. Also, this has made it clear my JAXB contexts loaded more classes than I thought and are basically duplicates of each other. I could go with one context encompassing all, but I’ve got an API of my own built around this separation.

Thanks for reading and any answers supplied.

  • 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-25T13:07:15+00:00Added an answer on May 25, 2026 at 1:07 pm

    I have the same issue and I do not think there is an easy answer. I found the source of the com.sun.tools.xjc.generator.bean.BeanGenerator class which appears to be responsible for generating the java source code (jaxb-xjc-2.1.4.jar). The code, starting from line 496 looks like this:

         if(model.options.target.isLaterThan(SpecVersion.V2_1)) {
            // @XmlSeeAlso
            Iterator<CClassInfo> subclasses = cc.target.listSubclasses();
            if(subclasses.hasNext()) {
                XmlSeeAlsoWriter saw = cc.implClass.annotate2(XmlSeeAlsoWriter.class);
                while (subclasses.hasNext()) {
                    CClassInfo s = subclasses.next();
                    saw.value(getClazz(s).implRef);
                }
            }
        }
    

    The XMLSeeAlso annotation appears to be hard-coded and NOT optional or configurable (at least with JAXB 2.1.4).

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

Sidebar

Related Questions

Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
Currently if i have dependency project opened, then maven use it instead of specified
Currently we use log4net of version 1.2.10.0 and we should start using some 3rd
Currently, the only information I have is a one-line error message in the browser's
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
Currently I'm doing some unit tests which are executed from bash. Unit tests are
Currently, I am developing a product that does fairly intensive calculations using MS SQL
currently we have a column with only integer values declared as NUMBER. At the
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these

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.