Issue
After upgrading to Mendix 10, the following error may occur during runtime:
java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverterThis error indicates that the application cannot find the javax.xml.bind.DatatypeConverter class, which is part of the Java Architecture for XML Binding (JAXB) API. This issue is often related to changes in Java versions and dependencies. Mendix 10 uses Java 11, which no longer includes the javax.xml.bind package as part of the JDK. Instead, the jakarta.xml.bind package is used in newer versions.
Environment
- Studio Pro v10
- Java 11 and above
Cause
The error occurs due to one or more of the following reasons:
- Outdated SQL server JDBC driver: The JDBC driver being used may not be compatible with Java 11 and still relies on the javax.xml.bind package.
- Conflicting JAR Files: The project may contain multiple versions of the JAXB API
The javax.xml.bind package was removed from Java 11 in favor of jakarta.xml.bind. However, if the project’s userlib folder contains conflicting libraries, the application might be trying to use classes from both namespaces, leading to the NoClassDefFoundError.
Example conflicted JAR library:
-
- jakarta.xml.bind-api-4.0.0.jar(references jakarta.xml.bind)
- jakarta.xml.bind-api-2.3.2.jar(references javax.xml.bind)
Solution/Workaround
Given the two possible causes listed above, firstly check if the JDBC drive version is compatible, then check if it contains duplicated jar files.
- Update SQL server JDBC driver
Navigate to the userlib folder in the project directory and locate the JDBC driver JAR file (e.g., mssql-jdbc-x.x.x.jrexx.jar for SQL Server)
- Check if the version is compatible with Java 11 through Release notes for the Microsoft JDBC Driver for SQL Server
- If not compatible, updating to the latest stable version
- Resolve conflicting JAR Files:
Navigate to the userlib folder in the project directory.
- Check if it contains duplicate JAR files, e.g., jakarta.xml.bind-api-4.0.0.jar and jakarta.xml.bind-api-2.3.2.jar
- Remove duplicate JAR file, e.g.,jakarta.xml.bind-api-2.3.2.jar.
- Clean deployment directory
Internal information related
- 207322, 240544
- C0TS72R9B/p1669736439455709
Additional information
Stack Overflow:
- Java 11 package javax.xml.bind does not exist [duplicate]
- "NoClassDefFoundError: javax/xml/bind/DatatypeConverter" with SQL Server JDBC
0 Comments