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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:08:24+00:00 2026-06-09T00:08:24+00:00

I have got problem with JAXB marshalling in Java 1.6_u33 I`ve got 5 schemas

  • 0

I have got problem with JAXB marshalling in Java 1.6_u33

I`ve got 5 schemas .xsd which are used for generating Java classes and then marshalling XML file.

Problem is with only one case – for this file JAXB generate additional namespace prefix ns2. This is very strange because all schemas are identical and marshalling mechnism is generic for all of them.

Generation mechanism:

    JAXBContext context = JAXBContext.newInstance(type);
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
            Boolean.TRUE);
    marshaller.marshal(file, doc);

And the first lines of bad xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ns2:Document xmlns:ns2="urn:iso:std:iso:20022:tech:xsd:camt.056.001.01">
  <ns2:camt.056.001.01>
    <ns2:Assgnmt>
      <ns2:Id>NOTPROVIDED</ns2:Id>
      <ns2:CreDtTm>2008-06-24T00:00:00</ns2:CreDtTm>
    </ns2:Assgnmt>

With the same settings xml generated from another xsd is:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.029.001.03">
  <camt.029.001.03>
    <Assgnmt>
      <Id>NOTPROVIDED</Id>
      <CreDtTm>2008-03-26T00:00:00</CreDtTm>
    </Assgnmt>

I would be very grateful for any help… Thanks.


I couldn`t add answer to my question so I add here my explanation.

For not properly working package:

Package-info:

@javax.xml.bind.annotation.XmlSchema(namespace = "urn:iso:std:iso:20022:tech:xsd:camt.056.001.01", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package eu.axabank.axaconverter.datamodel.camt056;

Object-factory

package eu.axabank.axaconverter.datamodel.camt056;

import javax.xml.bind.annotation.XmlRegistry;


/**
 * This object contains factory methods for each 
 * Java content interface and Java element interface 
 * generated in the eu.axabank.axaconverter.datamodel.camt056 package. 
 * <p>An ObjectFactory allows you to programatically 
 * construct new instances of the Java representation 
 * for XML content. The Java representation of XML 
 * content can consist of schema derived interfaces 
 * and classes representing the binding of schema 
 * type definitions, element declarations and model 
 * groups.  Factory methods for each of these are 
 * provided in this class.
 * 
 */
@XmlRegistry
public class ObjectFactory {


    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: eu.axabank.axaconverter.datamodel.camt056
     * 
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link CaseAssignmentBIC }
     * 
     */
    public CaseAssignmentBIC createCaseAssignmentBIC() {
        return new CaseAssignmentBIC();
    }

    /**
     * Create an instance of {@link UnderlyingTransaction }
     * 
     */
    public UnderlyingTransaction createUnderlyingTransaction() {
        return new UnderlyingTransaction();
    }

    /**
     * Create an instance of {@link PaymentTransactionInformation }
     * 
     */
    public PaymentTransactionInformation createPaymentTransactionInformation() {
        return new PaymentTransactionInformation();
    }

    /**
     * Create an instance of {@link RemittanceInformation }
     * 
     */
    public RemittanceInformation createRemittanceInformation() {
        return new RemittanceInformation();
    }

    /**
     * Create an instance of {@link OriginalTransactionReference }
     * 
     */
    public OriginalTransactionReference createOriginalTransactionReference() {
        return new OriginalTransactionReference();
    }

    /**
     * Create an instance of {@link ControlData }
     * 
     */
    public ControlData createControlData() {
        return new ControlData();
    }

    /**
     * Create an instance of {@link Document }
     * 
     */
    public Document createDocument() {
        return new Document();
    }

    /**
     * Create an instance of {@link CancellationReasonInformationBICorName }
     * 
     */
    public CancellationReasonInformationBICorName createCancellationReasonInformationBICorName() {
        return new CancellationReasonInformationBICorName();
    }

    /**
     * Create an instance of {@link ActiveOrHistoricCurrencyAndAmountEUR }
     * 
     */
    public ActiveOrHistoricCurrencyAndAmountEUR createActiveOrHistoricCurrencyAndAmountEUR() {
        return new ActiveOrHistoricCurrencyAndAmountEUR();
    }

    /**
     * Create an instance of {@link Camt056 }
     * 
     */
    public Camt056 createCamt056() {
        return new Camt056();
    }

}

For good working package:

package-info:

@javax.xml.bind.annotation.XmlSchema(namespace = "urn:iso:std:iso:20022:tech:xsd:camt.029.001.03", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package eu.axabank.axaconverter.datamodel.camt029;

And object factory looks exactly the same (except naming of course).

I have tried QName element – it is inconvenient due the generic nature of mechanizm – but withount any good result.

I was using NamespacePrefixMapper:

        NamespacePrefixMapper mapper = new NamespacePrefixMapper() {
            public String getPreferredPrefix(String namespaceUri,
                    String suggestion, boolean requirePrefix) {
                return "";
            }
        };
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
                mapper);

but this mapper did`t work! He was setting – but method getPreferredPrefix was never called during mershalling.

I don`t understand different beetwen my 4 schemas and this not working one…

  • 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-09T00:08:26+00:00Added an answer on June 9, 2026 at 12:08 am

    Problem detected!

    I am confused but it was my mistake.

    To get down to brass tacks:

    I generated 5 packages of Java classes from 5 different schemas. They were importing however one schema with simple types (common objects for schemas). I this common XSD I placed mainly objects….yeah mainly. There were 2 elements…unfortunately. This complexTypes were used only by object generated in this one – not working – case.

    The point is that 2 objects was generating from another Objectfactory – placed in another package!

    I deduce that mixing objects from more than one Object factory in one marshalling object couse problem descrbed in my first post.

    Clue is: If you dont want have many namespaces in XML u should never use two Object factories or import schemas with complex type.

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

Sidebar

Related Questions

I have got a problem with calling a global function, which takes a pointer
I have got a strange problem about in_array recently which I cannot understand. e.g.
I have got a Problem, I am developing an Application which should be able
I have got a problem about running codedui test which was generated from manual
I am new to XML & XSLT but have got this problem. I have
I have got problem with sending int from Java Client to C++ server. I
I have got a problem with Java serialization. Suppose I had one Object persisted
I have got a problem to get back a parameter from my view to
I have got a performance problem about TextField.htmlText +=msg .And I know that TextField.appendText(msg)
I have got very big problem because I would like to get more information

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.