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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:46:27+00:00 2026-05-13T01:46:27+00:00

I have an existing XML schema that contains a type that I would like

  • 0

I have an existing XML schema that contains a type that I would like to map to a Java Map of some sort using JAXB. My build process takes the schema and creates the beans. I would like to customize this process by having one of the complexTypes in my schema map to a java.util.Map. I’ve read somewhere that JAXB “can’t do interfaces.” I’m not sure if that applies in this case, but if so I’d be fine with it mapping to a HashMap. Also, it doesn’t necessarily have to be the complexType that maps to a Map, it could be an element if that’s what’s required.

I control my JAXB generation using a .xjb file, so I’m looking for some <jaxb:bindings> to put in there. I’ve tried the following, but it does not work:

<jaxb:bindings schemaLocation="myschema.xsd" node="/xs:schema">
    <jaxb:globalBindings>
        <jaxb:serializable uid="1"/>
    </jaxb:globalBindings>
    <jaxb:schemaBindings>
        <jaxb:package name="com.myschema.client.types"/>
    </jaxb:schemaBindings>
    <jaxb:bindings node="//xs:complexType[@name='MapType']">
            <jaxb:javaType name="java.util.HashMap"
            parseMethod="com.myschema.common.MapConverter.parseObjectToMap"
            printMethod="com.myschema.common.MapConverter.printMapToObject" />
    </jaxb:bindings>
</jaxb:bindings>

Edit: I’ve added more detail on the above binding that I’ve already tried. It generates the following error during schema compile:

[jaxb] [ERROR] compiler was unable to honor this javaType customization. It is attached to a wrong place, or its inconsistent with other bindings.

<jaxb:javaType> will not work because it can only be used for mapping between XML Schema primitives and Java types. Since I want to map between a complex type and a Java type, I cannot use this.

  • 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-13T01:46:27+00:00Added an answer on May 13, 2026 at 1:46 am

    Your XJC file is using the “standard” javaType directive, which I believe is limited to converting String values to and from a representative java type. As such, it’s only suitable for converting simple element and attribute content.

    The XJC tool provides an enhanced version of javaType, which in theory should be able to handle more complex structures. Unfortunately, this has yet to be implemented:

    https://java.net/jira/browse/JAXB-209 (unresolved)

    For instance, being able to map a
    schema type to a HashMap might be a
    likely requirement for those using
    model driven design/implementation.
    AFAICS, this is not possible today.
    Therefore, one must manually edit the
    generated code.

    Looks like you’re out of luck.

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

Sidebar

Related Questions

Currently, JAXB is creating a point class from the xml schema I have specified.
I have existing application which uses Sql server 2005 as a backend. It contains
I am using com.ctc.wstx.stax.WstxOutputFactory to generate XML. I am running wstx-asl-3.2.4 I need to
I'm currently trying to find a way of adding some extra elements to existing
Greetings, I have a complicated scenario to handle. I have a wsdl file which
I'm in the unfortunate situation where I need to consume web services that do
I am trying to automate our build/deployment process. So far I am using: a
I need to write a WSDL file to an existing web service which is
I've started a new job this week and am trying to get my head
Edit: Updated with input from Omlin I am attempting to add a custom button

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.