Deprecation of sun.jdk JBoss Module in JBoss EAP 8

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 8.x

Issue

  • The module sun.jdk is now deprecated in EAP 8.

  • Migrating application from EAP 7 / 6 to EAP 8, application throwing ClassNotFoundException looking for sun.misc.Unsafe

Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe from [Module "deployment.example.war" from Service Module Loader]
	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:200)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
	... 55 more

Resolution

Applications that have dependencies on the sun.jdk module from EAP should instead use the JDK module [Content from docs.oracle.com is not included.1]Content from docs.oracle.com is not included.1.

Such as:

  • java.base
  • java.corba
  • java.desktop
  • java.naming
  • java.rmi
  • java.security.jgss
  • java.sql.rowset
  • java.xml
  • java.xml.crypto
  • jdk.crypto.cryptoki
  • jdk.naming.dns
  • jdk.naming.rmi
  • jdk.security.auth
  • jdk.security.jgss
  • jdk.unsupported
  • jdk.xml.bind
  • ...

For example if an application needs to use the sun.misc which is in the JDK jdk.unsupported module, it would declare a dependency on it using the jboss-deployment-structure.xml such as shown below. See [4] for more information on declaring dependencies on modules.

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <deployment>
    <dependencies>
      <module name="jdk.unsupported"/>
    </dependencies>
  </deployment>
</jboss-deployment-structure>

[Content from docs.oracle.com is not included.1 JDK 11 Modules https://docs.oracle.com/en%2Fjava%2Fjavase%2F11%2Fdocs%2Fapi%2F%2F/java.base/module-summary.html]Content from docs.oracle.com is not included.1

Related Articles

  • [2 Deprecated in Red Hat JBoss Enterprise Application Platform (EAP) 8]2
  • [3 Getting java.lang.ClassNotFoundException: com.sun.jndi.dns.DnsContextFactory in JBoss EAP 8]3
  • [4 How to specify a dependency on a JBoss Module in JBoss EAP 8 / 7 / 6]4
Components
Category

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.