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

  • Home
  • SEARCH
  • 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 380459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:59:28+00:00 2026-05-12T14:59:28+00:00

We are using JAXB to handle our wsdl validation. In the wsdl we have

  • 0

We are using JAXB to handle our wsdl validation. In the wsdl we have an enumeration like so:

<xs:simpleType name="myEnum">
    <xs:annotation>
        <xs:documentation>The enums which matter.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:enumeration value="MYENUM_1">
            <xs:annotation>
                <xs:documentation>MYENUM_1 is the first enum.</xs:documentation>
            </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="MYENUM_2">
            <xs:annotation>
                <xs:documentation>MYENUM_2 is the second enum.</xs:documentation>
            </xs:annotation>
        </xs:enumeration>
    </xs:restriction>
</xs:simpleType>

If we pass in an invalid string as an enum for example, MYENUM_7, the value is set to null, instead of throwing an error like we would expect. Digging into the code, we find the following from RuntimeEnumLeafInfoImpl.java:

package com.sun.xml.bind.v2.model.impl;
//...
public T parse(CharSequence lexical) throws AccessorException, SAXException {
    // TODO: error handling

    B b = baseXducer.parse(lexical);
    if(b==null) {

        return null;
    }

    return parseMap.get(b);
}

It is clear to see that the parseMap is our list of enums, but if the key to the map, in this case the value of b, is not in the map it just returns null. We would like it to throw and exception of some sort if b is not in parseMap.

Short of fixing this and recompiling our own JAXB is there some other way to solve this?


EDIT: for clarification

We are using JAXB 2.1.9, and we want to unmarshall the data AND validate it. It is certainly possible I have overlooked something in the documentation about validation.

  • 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-12T14:59:28+00:00Added an answer on May 12, 2026 at 2:59 pm

    You are saying that you are using JAXB to validate data, but you are only describing an unexpected result after unmarshalling an XML document. In JAXB, validation and unmarshalling are two different and perhaps independent issues, since you can use JAXB in at least three different modes:

    • don’t validate
    • validate, report errors, but continue unmarshalling
    • validate and break on errors

    Are you sure that you’ve enabled schema validation on your unmarshaller and that you are evaluating potential errors? How to do that is rather different, depending on if you’re using JAXB 1.0 or 2.0, but the documentation should tell you how.

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

Sidebar

Related Questions

I have an Object that is being marshalled to XML using JAXB. One element
What are you using for binding XML to Java? JAXB, Castor, and XMLBeans are
Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I need to load wikipedia revision histories into POJOs, so I'm using JAXB to
I have an object graph that contains a cycle. How do I get JAXB
Using JAXB in Java it is easy to generate from a xml schema file
Using JAXB (2) is it possible to ensure that null values are not marshalled
I'm using JAXB to read and write XML. What I want is to use
Using PyObjC , you can use Python to write Cocoa applications for OS X.

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.