Bug 1395543

Summary: [GSS](6.4.z) Custom NameService by sun.net.spi.nameservice.provider.n doesn't work on EAP
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Osamu Nagano <onagano>
Component: Class LoadingAssignee: Petr Jurak <pjurak>
Status: CLOSED CURRENTRELEASE QA Contact: Peter Mackay <pmackay>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.3.2CC: bmaxwell, david.lloyd, jbilek, msochure, pjurak, pmackay, rstancel
Target Milestone: CR1   
Target Release: EAP 6.4.13   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-02-03 16:45:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1386335    
Attachments:
Description Flags
modules.zip none

Description Osamu Nagano 2016-11-16 07:19:39 UTC
As described in WFCORE-1998, custom implementation of sun.net.spi.nameservice.NameService doesn't work on EAP. Dependency to "sun.jdk:main" should be added into "org.jboss.as.server:main" because it is the TCCL when java.net.InetAddress is initialized.

Though this way of NameService customization will be removed in Java 9.

Comment 1 Osamu Nagano 2016-11-16 07:33:28 UTC
Created attachment 1221052 [details]
modules.zip

How to reproduce:

On EAP 6.4.11, prepend the attached module by editing standalone.conf like this.

  JBOSS_HOME=/path/to/eap6411
  JBOSS_MODULEPATH="/path/to/the/modules:$JBOSS_HOME/modules"
  ...
  JAVA_OPTS="$JAVA_OPTS -Dsun.net.spi.nameservice.provider.1=dns,MyNameService"

The custom name service provider impl, modules/sun/jdk/main/classes/com/example/MyNameService.java, will print a message to stdout if it is called.

    @Override
    public InetAddress[] lookupAllHostAddr(String string) throws UnknownHostException {
        System.out.println("*** MyNameService.lookupAllHostAddr called");
        return javaNativeNameService.lookupAllHostAddr(string);
    }

Deploy a test.jsp like below to call the method. The message won't appear unless you add the "sun.jdk:main" dependency to "org.jboss.as.server:main".

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <head>
        <title>Test Page</title>
    </head>
    <body>
        <%
            String name = request.getParameter("name");
            if (name == null) name = "www.redhat.com";
            java.net.InetAddress addr = java.net.InetAddress.getByName(name);
        %>
        
        <%=name%> maps to <%=addr.toString()%>.
        
    </body>
</html>

Comment 2 Petr Jurak 2016-11-21 10:09:36 UTC
PR: https://github.com/jbossas/jboss-eap/pull/2884

Comment 3 Jiří Bílek 2017-01-13 08:29:56 UTC
Verified with EAP 6.4.13.CP.CR2

Comment 4 Petr Penicka 2017-02-03 16:45:59 UTC
Released with EAP 6.4.13 on Feb 02 2017.