Bug 824102

Summary: [as5] server discovery sometimes discovers a JNP URL containing an IPv6 address surrounded by square brackets (e.g. "jnp://[0:0:0:0:0:0:0:1]:1099"), and the plugin fails to connect to the URL
Product: [Other] RHQ Project Reporter: Ian Springer <ian.springer>
Component: PluginsAssignee: RHQ Project Maintainer <rhq-maint>
Status: NEW --- QA Contact: Mike Foley <mfoley>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.4CC: hbrock, hrupp, staffan.horke
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=822218
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 919199    

Description Ian Springer 2012-05-22 14:04:43 EDT
The discovery code reads the JNP URL from $JBOSS_EAP_HOME/server/<ACTIVE_CONFIGURATION>/data/jnp-service.url. Note that this is not a configuration file but a file JBoss EAP creates while starting up. This was done to ease the problem of finding the correct values in the AS configuration files for management software like RHQ. 

For whatever reason (perhaps when IPv6 is set as preferred), AS5 sometimes sets the URL in this file to "jnp://[0:0:0:0:0:0:0:1]:1099", yet the AS5 JNP client does not support connecting to such URL's that contain square brackets (see 

I think we may be able to workaround the JBAS bug in cases where the IPv6 address can be converted to an IPv4 address, e.g.:


String jnpHost = jnpUri.getHost();
String normalizedJnpHost = jnpHost;
InetAddress ipAddress = IntetAddress.getByName(jnpHost);
if (ipAddress instanceof Inet6Address) {
   Inet6Address ipv6Address = (Inet6Address)ipAddress;
   if (ipv6Address.isIPv4CompatibleAddress()) {
       if (ipv6Address.isLoopbackAddress()) {
           normalizedJnpHost = "";
       } else {
           byte[] ipv6Bytes = ipv6Address.getAddress();
           byte[] ipv4Bytes = Arrays.copyOfRange(ipv6Bytes, 12, 16);       
           InetAddress ipv4Address = InetAddress.getByAddress(ipv4Bytes);
           normalizedJnpHost = ipv4Address.toString();
String normalizedJnpUri = "jnp://" + normalizedJnpHost + ":" + jnpUri.getPort();
Comment 1 Ian Springer 2012-05-22 14:12:44 EDT
This was reported in this user forum thread:

Comment 2 Staffan Hörke 2012-05-24 07:55:34 EDT
In my case I run JBAS 6.1.0.Final bound to and the jnp-service.url contains a IPv4 address jnp:// From the agent log it looks like the file is read correctly:

2012-05-22 17:24:35,078 DEBUG [ResourceDiscoveryComponent.invoker.daemon-1] (org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent)- Read JNP URL from jnp-service.url file: jnp://

However, to connect it later uses an IPv6 address, which fails:

2012-05-22 17:24:44,894 DEBUG [InventoryManager.discovery-1] (rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvider)- Connecting to Profile Service via remote JNDI using env [{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.provider.url=jnp://[0:0:0:0:0:0:0:1]:1199, jnp.disableDiscovery=true, jnp.timeout=60000, jnp.sotimeout=60000}]...
2012-05-22 17:24:44,894 DEBUG [InventoryManager.discovery-1] (org.rhq.plugins.jbossas5.ApplicationServerComponent)- Failed to connect to Profile Service.
Caused by: javax.naming.CommunicationException: Could not obtain connection to any of these urls: [0:0:0:0:0:0:0:1]:1199 [Root exception is javax.naming.CommunicationException: Failed to connect to server /0:0:0:0:0:0:0:1:1199 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server /0:0:0:0:0:0:0:1:1199 [Root exception is java.net.SocketException: Protocol family unavailable]]]

JBAS 6.1.0.Final
RHQ 4.4.0

JBAS + agent on one machine. RHQ server on another. I disabled IPv6 on Windows with the same result.

Running the same setup with RHQ 4.2.0 works
Comment 3 Ian Springer 2012-05-24 16:22:19 EDT
Thanks, this info will be very helpful in getting to the bottom of this. 

One question for you: does your Agent JVM command line contain either of the following options?

Comment 4 Ian Springer 2012-05-24 16:24:56 EDT
Actually can you also check if your AS 6.1 JVM command line has either of those options?
Comment 5 Mike Foley 2012-05-29 10:41:21 EDT
per BZ Triage 5/29/2012 (ccrouch, loleary, asantos, mfoley, myarborough) moving these to JON 3.1.1 or later
Comment 6 Staffan Hörke 2012-05-31 05:42:46 EDT
Agent JVM contains (inst default)

AS 6.1 did not contain any of the above.

When 4.4.0 failed I tried RHQ 4.2.0 which worked (inst default). After your feedback added -Djava.net.preferIPv4Stack=true to AS 6.1 JAVA_OPTS and tried RHQ 4.4.0. Now my agent connects to the IPv4 url.

However, after discovery success I fail to reproduce the error, even by removing -Djava.net.preferIPv4Stack=true from AS 6.1. So I cannot confirm what actually made it work.