I have the Java code below that works fine on a basic Main class example. Great!
However, when it's deployed on Wildfly (10.0.0) application server the mentioned class isn't found and an exception is thrown. I've tested on another application server like IBM Websphere Application (8.0 and 9.0) and it also works.
Does someone have an idea why does this happens on Wildfly?
The Code:
String resConfName = "sun.net.dns.ResolverConfiguration";
Class resConfClass = Class.forName(resConfName);
The Exception:
java.lang.ClassNotFoundException: sun.net.dns.ResolverConfiguration from [Module "deployment.myApp.ear.myApp.war:main" from Service Module Loader]
My Wildfly Environment: (sad face)
My Websphere 8 Environment: (happy face)
My Websphere 9 Environment: (happy face)
Simple main example: (happy face)
Thank you in advance!
There are some notes in the WildFly developer guide about this.
https://docs.wildfly.org/19/Developer_Guide.html#accessing-jdk-classes
By default, not all JDK classes are exposed to deployments. So you need to set up a system dependency in jboss-deployment-structure.xml
like this.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<system export="true">
<paths>
<path name="sun/net/dns"/>
</paths>
</system>
</dependencies>
</deployment>
</jboss-deployment-structure>
In later versions of WildFly (18, 19) this seems to be working without the need to do this.