Error "javax.xml.datatype.DatatypeConfigurationException: Provider __redirected.__DatatypeFactory not found" with EAP 6

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform
    • 6.x

Issue

With the EAP 6.1, we are receiving the below exception from one of our class.

javax.xml.datatype.DatatypeConfigurationException: Provider __redirected.__DatatypeFactory not found 

Resolution

1. Setup module "com.sun.xml.bind" correctly

By editing jboss-deployment-descriptor.xml and set dependency as below, the issue is resolved.

<module name="com.sun.xml.bind" export="true" services="export"/>

There is a similar discussion in JBoss community: Using JAXB and see java.lang.ClassNotFoundException: __redirected/__DatatypeFactory.

For more information please check Using JAXB

2. Setup TCCL(Thread Context Class Loader) correctly, or use a Java EE standard way to create threads
If you are trying to create threads in your own code, and getting this issue, you either need to:

  • Fix the code to set the TCCL for the custom thread;
  • Use an EE standard way to run tasks, such as an EJB timer or JMS, where EAP will be responsible for creating threads correctly.

Root Cause

1. The module "com.sun.xml.bind" is not set correctly

In order for successfully directly using JAXB contexts, etc. in your client or endpoint running in-container, you need to properly setup a JAXB implementation.

2. TCCL(Thread Context Class Loader) is not set correctly

When EAP creates threads, it sets the TCCL to the correct value (JBoss Modules classloader). So that the custom modules are available to the newly created threads.
If you are trying to create a thread in your own code, then you are responsible to setup the TCCL correctly. In the case that TCCL was not setup correctly (TCCL = null), you will get "ClassNotFoundException" because the class cannot be found in system or boot classloader:

Caused by: java.lang.ClassNotFoundException: __redirected/__DatatypeFactory

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.