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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:22:27+00:00 2026-06-14T01:22:27+00:00

In our product we use apache CXF. Because of performance restriction, the schema validation

  • 0

In our product we use apache CXF. Because of performance restriction, the schema validation has been set to false. Now, for an integer element if I am providing an invalid value, JAXB is unmarshaling it to some thing else. For example,

9999999999 is converted into 1410065407.

988888888888 is converted into 1046410808.

My question is what is the logic (formula) that is being followed here?

How to handle this (Considering the validation will be off)? I want such a value to be rejected.

  • 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-14T01:22:28+00:00Added an answer on June 14, 2026 at 1:22 am

    Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

    SHORT ANSWER

    This appears to be a bug in the JAXB reference implementation. I would recommend entering a bug for it at the following location:

    • http://java.net/jira/browse/JAXB/

    This same use case works correctly in EclipseLink JAXB (MOXy).


    LONG ANSWER

    Below is a complete example that demonstrates the issue:

    Root

    Below is a domain class with int and integer fields.

    package forum13216624;
    
    import javax.xml.bind.annotation.*;
    
    @XmlRootElement
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Root {
    
        int int1;
        int int2;
        Integer integer1;
        Integer integer2;
    
    }
    

    input.xml

    Below is an XML document with the values from your question.

    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <int1>9999999999</int1>
        <int2>988888888888</int2>
        <integer1>9999999999</integer1>
        <integer2>988888888888</integer2>
    </root>
    

    Demo

    In the demo code below I’ve specified a ValidationEventHandler on the Unmarshaller. This should catch a ValidationEvent for any invalid values encountered during an unmarhsal operation.

    package forum13216624;
    
    import java.io.File;
    import javax.xml.bind.*;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(Root.class);
    
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            unmarshaller.setEventHandler(new ValidationEventHandler() {
    
                @Override
                public boolean handleEvent(ValidationEvent event) {
                    System.out.println(event.getMessage());
                    return true;
                }}
    
            );
            File xml = new File("src/forum13216624/input.xml");
            Root root = (Root) unmarshaller.unmarshal(xml);
    
            System.out.println(root.int1);
            System.out.println(root.int2);
            System.out.println(root.integer1);
            System.out.println(root.integer2);
        }
    
    }
    

    Output – JAXB Reference Implementation

    This output matches the behaviour you are seeing.

    1410065407
    1046410808
    1410065407
    1046410808
    

    Output – EclipseLink JAXB (MOXy)

    If you specify MOXy as your JAXB provider (see: http://blog.bdoughan.com/2011/05/specifying-eclipselink-moxy-as-your.html) this use case works as expected. You will get a ValidationEvent for each invalid value, and if the ValidationEvent is handled the field/property won’t be set to a invalid value.

    Exception Description: The object [9999999999], of class [class java.lang.String], from mapping [org.eclipse.persistence.oxm.mappings.XMLDirectMapping[int1-->int1/text()]] with descriptor [XMLDescriptor(forum13216624.Root --> [DatabaseTable(root)])], could not be converted to [class java.lang.Integer].
    Internal Exception: java.lang.NumberFormatException: For input string: "9999999999"
    
    Exception Description: The object [988888888888], of class [class java.lang.String], from mapping [org.eclipse.persistence.oxm.mappings.XMLDirectMapping[int2-->int2/text()]] with descriptor [XMLDescriptor(forum13216624.Root --> [DatabaseTable(root)])], could not be converted to [class java.lang.Integer].
    Internal Exception: java.lang.NumberFormatException: For input string: "988888888888"
    
    Exception Description: The object [9999999999], of class [class java.lang.String], from mapping [org.eclipse.persistence.oxm.mappings.XMLDirectMapping[integer1-->integer1/text()]] with descriptor [XMLDescriptor(forum13216624.Root --> [DatabaseTable(root)])], could not be converted to [class java.lang.Integer].
    Internal Exception: java.lang.NumberFormatException: For input string: "9999999999"
    
    Exception Description: The object [988888888888], of class [class java.lang.String], from mapping [org.eclipse.persistence.oxm.mappings.XMLDirectMapping[integer2-->integer2/text()]] with descriptor [XMLDescriptor(forum13216624.Root --> [DatabaseTable(root)])], could not be converted to [class java.lang.Integer].
    Internal Exception: java.lang.NumberFormatException: For input string: "988888888888"
    0
    0
    null
    null
    

    POTENTIAL WORKAROUND

    If your fields/properties are of type Integer and you can switch from the JAXB reference implementation then you could create an XmlAdapter to do your own Integer to/from String conversions.

    IntegerAdapter

    Below is an example of an XmlAdapter demonstrating how you could provide your own conversion logic.

    package forum13216624;
    
    import javax.xml.bind.annotation.adapters.XmlAdapter;
    
    public class IntegerAdapter extends XmlAdapter<String, Integer>{
    
        @Override
        public Integer unmarshal(String string) throws Exception {
            return Integer.valueOf(string);
        }
    
        @Override
        public String marshal(Integer integer) throws Exception {
            return String.valueOf(integer);
        }
    
    }
    

    package-info

    Using the @XmlJavaTypeAdapter annotation at the package level means that the XmlAdapter will apply to all fields/properties of type Integer for classes in this package.

    @XmlJavaTypeAdapter(value=IntegerAdapter.class, type=Integer.class)
    package forum13216624;
    
    import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
    

    Output

    Below is the updated output when the RI is used. The int values are still wrong, but not the Integer values are null and ValidationEvents are produced as expected.

    java.lang.NumberFormatException: For input string: "9999999999"
    java.lang.NumberFormatException: For input string: "988888888888"
    1410065407
    1046410808
    null
    null
    

    For More Information

    • http://blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into IKVMing Apache's FOP project to use with our .NET
We use Apache Continuum for our continous builds now and it FTP's the build
I work for a ISV. Our product can use both SQL Server and Oracle
We use Make to compile our product, which includes, C, C++, Java and a
Our product has two clients, a website and a windows application. Both clients need
Currently we use .wav files for storing our sounds with our product. However, these
I work at a corporation. We want to use Eclipse to create our product
One of our product publishes a webservice using contract-last approach. This has becoming a
A single installation of our product stores it's configuration in a set of database
In our eclipse product we use svn revision number substitution in qualifier. Building and

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.