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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:40:30+00:00 2026-06-03T17:40:30+00:00

I have an XML like: <message xmlns:gtm=http:// www.example.com/working/gtm> <gtm:header> <someid></someid> <sometext></sometext> </gtm:header> <gtm:customer>0123456789</gtm:customer> </message>

  • 0

I have an XML like:

<message  xmlns:gtm="http:// www.example.com/working/gtm">
    <gtm:header>
    <someid></someid>
    <sometext></sometext>
    </gtm:header>
    <gtm:customer>0123456789</gtm:customer>
</message>

I am using @XmlPath mappings. but when I run the code I get this error:

Exception [EclipseLink-25016] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A namespace for the prefix gtm:header was not found in the namespace resolver.

I wonder what am I missing?

  • 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-03T17:40:32+00:00Added an answer on June 3, 2026 at 5:40 pm

    Below is an example of how you can map your use case with EclipseLink JAXB (MOXy).

    package-info

    First you need to set up the namespace information using the package level @XmlSchema annotation. We will leverage the namespace prefixes specified with the @XmlNs annotation later with the @XmlPath annotation.

    @XmlSchema(
        namespace="http:// www.example.com/working/gtm",
        xmlns={
            @XmlNs(prefix="gtm", namespaceURI="http:// www.example.com/working/gtm")
        },
        elementFormDefault=XmlNsForm.UNQUALIFIED)
    package forum10548370;
    
    import javax.xml.bind.annotation.*; 
    

    Message

    The @XmlPath annotation is used to specify an XPath based mapping with MOXy. Since in the @XmlSchema annotation we specified elementFormDefault=XmlNsForm.UNQUALIFIED, the portions of the XPath without a prefix will not be namespace qualified.

    package forum10548370;
    
    import javax.xml.bind.annotation.*;
    import org.eclipse.persistence.oxm.annotations.XmlPath;
    
    @XmlRootElement(name="message", namespace="")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Message {
    
        @XmlPath("gtm:header/someid/text()")
        private String id;
    
        @XmlPath("gtm:header/sometext/text()")
        private String text;
    
        @XmlElement(namespace="http:// www.example.com/working/gtm")
        private String customer;
    
    }
    

    jaxb.properties

    To specify MOXy as your JAXB provider you need to add a file called jaxb.properties in the same package as your domain model with the following entry (see http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html):

    javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
    

    Demo

    package forum10548370;
    
    import java.io.File;
    import javax.xml.bind.*;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(Message.class);
    
            File xml = new File("src/forum10548370/input.xml");
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            Message message = (Message) unmarshaller.unmarshal(xml);
    
            Marshaller marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.marshal(message, System.out);
        }
    
    }
    

    input.xml/Output

    <?xml version="1.0" encoding="UTF-8"?>
    <message xmlns:gtm="http:// www.example.com/working/gtm">
       <gtm:header>
          <someid></someid>
          <sometext></sometext>
       </gtm:header>
       <gtm:customer>0123456789</gtm:customer>
    </message>
    

    For More Information

    • http://blog.bdoughan.com/2010/09/xpath-based-mapping-geocode-example.html
    • http://blog.bdoughan.com/2010/08/jaxb-namespaces.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML document: <application xmlns=http://www.example.com/schemas/app-config/1.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.example.com/schemas/app-config/1.0 http://www.example.com/schemas/app-config/1.0/app-config-1.0.xsd> <info name=Dummy Application
I have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <xs:msgdata xmlns:xs=http://www.myCompany.com
I have the following XML: <soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:axis=http://ws.apache.org/axis2> <soapenv:Header/> <soapenv:Body> <axis:ErrorQueueInput> <errorStr>JIRA Topic</errorStr> <InputMessage>
I have a part of xml file <Text>&lt;?xml version=1.0 encoding=utf-16?&gt; &lt;ObjectFilter xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema&gt; &lt;FilterConditions&gt;
I have XSLT like: <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:fo=http://www.w3.org/1999/XSL/Format xmlns:xs=http://www.w3.org/2001/XMLSchema xmlns:fn=http://www.w3.org/2005/xpath-functions> ....... <xsl:value-of select=format-number(abs(QUANTITY), '#')/>
I have a problem: with this xml layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent
I have PreferenceActivity with some sample content: <?xml version=1.0 encoding=utf-8?> <PreferenceScreen xmlns:android=http://schemas.android.com/apk/res/android> <PreferenceCategory android:title=First
I have code like this: // Take the xml message and turn it into
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
I have a relatively simple Soap response message XML which I'd like to modify

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.