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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:20:05+00:00 2026-05-29T05:20:05+00:00

When i create a jaxbcontext with all my classes, jaxb build xml for a

  • 0

When i create a jaxbcontext with all my classes, jaxb build xml for a class with a namespace from other class.
If i pass to jaxbcontext only one class it work fine.
My classes are generated by xjc.

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {

 })
@XmlRootElement(name = "eReq")
public class EReq {
...

And when i pass only this class to jaxbcontext the output is following.

<eReq><status>UNBLOCKED</status></eReq>

But i put all my classes into jaxb context output will be like this:

<eReq xmlns:ns2="myns1" xmlns:ns3="myns2" xmlns:ns4="http://schemas.xmlsoap.org/soap/envelope/"><status>UNBLOCKED</status></eReq>

This is namespaces from my other classes. Why jaxb put it to this class?

  • 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-29T05:20:06+00:00Added an answer on May 29, 2026 at 5:20 am

    Why jaxb put it to this class?

    Because the JAXB context contains the superset of all namespaces that it’s created with, and it just puts them all in each document it generates.

    It does this because the namespaces need to be added to the root element (to avoid hugely wasteful re-declaration of namespaces on each child element), and it doesn’t know in advance which namespaces are required for any given set of bound objects (JAXB supports incremental serialization).

    So the JAXB runtime probably could avoid doing that; but it doesn’t.

    If you don’t like it, then you need to build multiple contexts.

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

Sidebar

Related Questions

I am trying to unmarshall a XML document created from jersey JAXB annotated class.
I am trying to create java objects from xml file. I am using jaxb(unmarshalling)
CREATE MATERIALIZED VIEW ORDERS_MV BUILD IMMEDIATE REFRESH COMPLETE ON DEMAND AS SELECT * FROM
I have a class that unmarshals xml from a 3rd party source (I have
Hi I'm very new to XML, and webservices but I'm recieving XML from a
We're parsing an XML document using JAXB and get this error: [org.xml.sax.SAXParseException: Invalid byte
I've created an XML schema by annotating an existing Java domain model class, now
When trying to create a new JAXB instance inside a servlet I am getting
BufferedWriter out = new BufferedWriter(fstream); try { JAXBContext context = JAXBContext.newInstance(NarociloType.class); Marshaller m =
// Create a scanner that reads from the input stream passed to us CSLexer

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.