Note that system properties including JAXBContext cannot be used in Java11

It took a long time and it was quite difficult, so I made a memorandum.

During development, there was talk of updating the Java version of a project that was working so far to 11.

In conclusion, I got stuck with an endless error containing a message like the one below.

JAXBContext cannot be resolved The import javax.xml.bind cannot be resolved

There were other errors, but the point is that the previously used libraries such as javax.xml.bind suddenly became unusable.

environment

Java11(jdk-11.0.1) Spring Tool Suite 3.9.6.RELEASE

Solution

Add the following to pom.xml

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.0</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>javax.activation-api</artifactId>
    <version>1.2.0</version>
</dependency>

You need to prepare a library that is said to be missing.

Oracle JDK 11 Release Notes

There was an item called Removed Features and Options in Oracle's JDK 11 Release Notes. It seems that some system properties will be unavailable from Java 11.

↓ Copy the area that was related to you. (The library where the deficit was angry)

In addition, the following system properties are no longer applicable due to the the removal of the Java EE and CORBA modules:

com.sun.xml.internal.ws.client.ContentNegotiation com.sun.xml.internal.ws.legacyWebMethod javax.xml.bind.context.factory javax.xml.bind.JAXBContext javax.xml.soap.MetaFactory javax.xml.ws.spi.Provider jaxb.fragment jaxb.noNamespaceSchemaLocation jaxb.schemaLocation jaxb.formatted.output jaxb.encoding

The whole story is written in the release notes.

■ Release notes https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html

■ Removed Features and Options https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#Removed

There are many other things such as mail.mime missing.

The project that used the library deleted here until now was that if you update to Java 11 without preparation, an error will naturally occur.

reference

A page I found while searching to solve the above error (I didn't know the cause at that time)

https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j

https://github.com/authzforce/restful-pdp/issues/4

Recommended Posts

Note that system properties including JAXBContext cannot be used in Java11
Please note that Spring Boot + Tomcat 8.5.8 cannot be used!
Summary of ORM "uroboroSQL" that can be used in enterprise Java
Java code that cannot be used from Kotlin (for in-house study sessions)
Why Java String typeclass comparison (==) cannot be used
Technology excerpt that can be used for creating EC sites in Java training
Check with Java / Kotlin that files cannot be written in UAC on Windows
Write a class that can be ordered in Java
Convenient shortcut keys that can be used in Eclipse
Syntax and exception occurrence conditions that can be used when comparing with null in Java
[Java 8] Sorting method in alphabetical order and string length order that can be used in coding tests
[Java] It seems that `0 <hoge <10` cannot be written in the conditional expression of the ʻif` statement.
The case that @Autowired could not be used in JUnit5
Java (super beginner edition) that can be understood in 180 seconds
Java 14 new features that could be used to write code
[rails] Problems that cannot be registered / logged in with devise
Because getSupportLoaderManager cannot be used
Cannot find javax.annotation.Generated in Java 11
Java Stream cannot be reused.
Reference memo / In-memory LDAP server that can be embedded in Java
Static analysis tool that can be used on GitHub [Java version]
Three reasons why wrapper classes should not be used in Java
Text file placed in resources in Java cannot be read when jarted
SwiftUI View that can be used in combination with other frameworks
It seems that data class-like functions will be added in Java14
[Swift] Note that you cannot delete only specific cells in TableView
[Java 8] Until converting standard input that can be used in coding tests into a list or array
CentOS7 VirtualBOX yum cannot be used
Java version notation that changes in Java 10
Read Java properties file in C #
[PHP] Solved "mb_strpos cannot be used"
Java cannot be installed on Ubuntu 13.04
Java file input / output processing that can be used through historical background
The story that the Servlet could not be loaded in the Java Web application
[Android Studio] Description that can be continuously input in SQLite Database [Java]
[Java] Variables declared inside the `for statement` cannot be used outside the` for statement block`