Bug 903402 - Discovery of JBoss AS instance fails when JBOSS_HOME or CLASSPATH omits a Windows drive letter
Summary: Discovery of JBoss AS instance fails when JBOSS_HOME or CLASSPATH omits a Win...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: Plugin -- JBoss EAP 4, Plugin -- JBoss EAP 5
Version: JON 3.1.1
Hardware: All
OS: Windows
urgent
high
Target Milestone: ER07
: JON 3.2.0
Assignee: John Mazzitelli
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: 1012435
TreeView+ depends on / blocked
 
Reported: 2013-01-23 22:10 UTC by Larry O'Leary
Modified: 2018-11-30 20:20 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Microsoft Windows EAP 4 or EAP 5
Last Closed: 2014-01-02 20:36:04 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Proposed fix for both JBoss AS 4 and AS 5 plug-ins to handle absolute paths without a drive letter. (1.78 KB, patch)
2013-01-23 23:15 UTC, Larry O'Leary
no flags Details | Diff
eap5 connection settings (80.60 KB, image/png)
2013-11-05 14:59 UTC, Filip Brychta
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 284143 0 None None None Never

Description Larry O'Leary 2013-01-23 22:10:34 UTC
Description of problem:
User has raised an issue in where JBoss AS/EAP instances on Windows are not being discovered when the paths used by AS are not prefixed with a drive letter. For example, instead of C:\jboss\jboss-eap-5.1\bin\run.jar it is \jboss\jboss-eap-5.1\bin\run.jar. Although the JBoss AS instance is fully working and does not require the drive letter, the AS4 and AS5 utilize the File.isAbsolute() method which assumes that on Windows, no drive letter equals a relative path.

This is being treated as a bug because it is completely valid for the path to omit the drive letter. Especially within a shared environment. The drive is determined based on the executing process' active drive. 

Version-Release number of selected component (if applicable):
4.4.0.JON311GA

How reproducible:
Always

Steps to Reproduce:
1.  Setup a Windows system (Windows Server 2008 R2) that has a secondary/additional disk drive (E:).
2.  Create the base installation directory for JBoss EAP:

        E:
        mkdir E:\opt\jboss\eap

3.  Extract JBoss EAP 5 to E:\opt\jboss\eap\.
4.  Create JBoss ON agent base installation directory:

        E:
        mkdir E:\opt\jboss\jon

5.  Install ON agent in E:\opt\jboss\jon:

        cd E:\opt\jboss\jon
        java -jar C:\tmp\rhq-enterprise-agent-4.4.0.JON311GA.jar -i

6.  Set JBOSS_HOME to /opt/jboss/eap/jboss-eap-5.1/jboss-as:

        set JBOSS_HOME=/opt/jboss/eap/jboss-eap-5.1/jboss-as
        
7.  Start EAP default profile from E:\opt using absolute path:

        E:
        cd E:\opt
        "%JBOSS_HOME%/bin/run" -c default -b 0.0.0.0
        
8.  Start JBoss ON system.
9.  Wait for agent's AS5 plug-in to perform its discovery scan.
  
Actual results:
Discovery of the EAP 5 server will fail and the following message will appear in the agent's log file:

    DEBUG [ResourceDiscoveryComponent.invoker.daemon-1] (rhq.plugins.jbossas5.helper.JBossInstanceInfo)- Parsing JBossAS command line [C:\Program Files\Java\jre6\bin\java, -Djava.net.preferIPv4Stack=true, -Dprogram.name=run, -server, -Djava.endorsed.dirs=/opt/jboss/eap/jboss-eap-5.1/jboss-as\lib\endorsed, -classpath, /opt/jboss/eap/jboss-eap-5.1/jboss-as\bin\run.jar, org.jboss.Main, -c, default, -b, 0.0.0.0]...
    ERROR [ResourceDiscoveryComponent.invoker.daemon-1] (org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent)- Failed to process JBoss AS command line: [C:\Program Files\Java\jre6\bin\java, -Djava.net.preferIPv4Stack=true, -Dprogram.name=run, -server, -Djava.endorsed.dirs=/opt/jboss/eap/jboss-eap-5.1/jboss-as\lib\endorsed, -classpath, /opt/jboss/eap/jboss-eap-5.1/jboss-as\bin\run.jar, org.jboss.Main, -c, default, -b, 0.0.0.0]
    java.lang.Exception: Could not determine JBossAS home dir - classpath is: [/opt/jboss/eap/jboss-eap-5.1/jboss-as\bin\run.jar]
	    at org.rhq.plugins.jbossas5.helper.JBossInstanceInfo.getHomeDir(JBossInstanceInfo.java:263)
	    at org.rhq.plugins.jbossas5.helper.JBossInstanceInfo.finalizeSysProps(JBossInstanceInfo.java:271)
	    at org.rhq.plugins.jbossas5.helper.JBossInstanceInfo.<init>(JBossInstanceInfo.java:90)
	    at org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent.discoverExternalJBossAsProcesses(ApplicationServerDiscoveryComponent.java:267)
	    at org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent.discoverResources(ApplicationServerDiscoveryComponent.java:170)
	    at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
	    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	    at java.lang.reflect.Method.invoke(Unknown Source)
	    at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:293)
	    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	    at java.util.concurrent.FutureTask.run(Unknown Source)
	    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	    at java.lang.Thread.run(Unknown Source)


Expected results:
EAP 5 server should be discovered and no error should be reported.

Additional info:
The cause for this is in the getHomeDir methods of the AS4 and AS5 plug-ins prefixes the class path entry with the JVM's working directory when isAbsolute returns false. Essentially making:

    \jboss\jboss-eap-5.1\bin\run.jar 

Into:

    C:\jboss\jboss-eap-5.1\bin\jboss\jboss-eap-5.1\bin\run.jar

Comment 1 Larry O'Leary 2013-01-23 23:15:42 UTC
Created attachment 686339 [details]
Proposed fix for both JBoss AS 4 and AS 5 plug-ins to handle absolute paths without a drive letter.

To fix this issue, my proposed patch is simply adding a check to see if the runJar file exists or not before attempting to resolve an absolute path:

                if (!runJar.isAbsolute()) {...

Becomes:
                if (!runJar.isAbsolute() && !runJar.exists()) {...

Comment 2 John Mazzitelli 2013-05-10 19:57:08 UTC
git commit to master: d2523a0

this BZ's description provides replication procedures

Comment 3 Larry O'Leary 2013-09-06 14:32:49 UTC
As this is MODIFIED or ON_QA, setting milestone to ER1.

Comment 4 Filip Brychta 2013-11-05 14:58:24 UTC
Discovery is fixed but the AS 5 resource is unavailable after import. This is caused by 
Caused by: org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException: Configuration path 'e:\opt\jboss\jboss-eap-5.2\jboss-as\opt\jboss\jboss-eap-5.2\jboss-as\server\default' does not exist.

Configuration path is concatenation of 'JBoss Home Directory' and 'Server Home Dir'. See attached screen shot.

Scenario:
1- follow steps 1 to 9 from previous description.
2- import AS 5 resource from discovery queue

Result:
The AS 5 resource is not available and rhq agent is throwing following warning:
2013-11-05 01:43:59,330 DEBUG [InventoryManager.availability-1] (rhq.core.pc.inventory.InventoryManager)- Resource has a bad config, waiting for this to go away: Resource[id=10124, uuid=3d451234-7e96-4150-84ec-a4a3c666f56c, type={JBossAS5}JBossAS Server, key=E:\opt\jboss\jboss-eap-5.2\jboss-as\opt\jboss\jboss-eap-5.2\jboss-as\server\default, name=EAP 127.0.0.1:1199 default, parent=10.16.23.233, version=EAP 5.2.0]
2013-11-05 01:43:59,331 WARN  [InventoryManager.availability-1] (rhq.core.pc.inventory.AvailabilityExecutor)- Availability collection failed with exception on Resource[id=10124, uuid=3d451234-7e96-4150-84ec-a4a3c666f56c, type={JBossAS5}JBossAS Server, key=E:\opt\jboss\jboss-eap-5.2\jboss-as\opt\jboss\jboss-eap-5.2\jboss-as\server\default, name=EAP 127.0.0.1:1199 default, parent=10.16.23.233, version=EAP 5.2.0], availability will be reported as DOWN
org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException: Failed to start component for resource Resource[id=10124, uuid=3d451234-7e96-4150-84ec-a4a3c666f56c, type={JBossAS5}JBossAS Server, key=E:\opt\jboss\jboss-eap-5.2\jboss-as\opt\jboss\jboss-eap-5.2\jboss-as\server\default, name=EAP 127.0.0.1:1199 default, parent=10.16.23.233, version=EAP 5.2.0].
        at org.rhq.core.pc.inventory.InventoryManager.activateResource(InventoryManager.java:1937)
        at org.rhq.core.pc.inventory.AvailabilityExecutor.checkInventory(AvailabilityExecutor.java:343)
        at org.rhq.core.pc.inventory.AvailabilityExecutor.startScan(AvailabilityExecutor.java:197)
        at org.rhq.core.pc.inventory.CustomScanRootAvailabilityExecutor.startScan(CustomScanRootAvailabilityExecutor.java:71)
        at org.rhq.core.pc.inventory.AvailabilityExecutor.call(AvailabilityExecutor.java:152)
        at org.rhq.core.pc.inventory.AvailabilityExecutor.call(AvailabilityExecutor.java:62)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException: Configuration path 'e:\opt\jboss\jboss-eap-5.2\jboss-as\opt\jboss\jboss-eap-5.2\jboss-as\server\default' does not exist.
        at org.rhq.plugins.jbossas5.ApplicationServerComponent.getConfigurationPath(ApplicationServerComponent.java:590)
        at org.rhq.plugins.jbossas5.ApplicationServerComponent.start(ApplicationServerComponent.java:195)
        at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.rhq.core.pc.inventory.ResourceContainer$ComponentInvocation.call(ResourceContainer.java:654)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)

Comment 5 Filip Brychta 2013-11-05 14:59:22 UTC
Created attachment 819814 [details]
eap5 connection settings

Comment 6 Mike Foley 2013-11-11 15:09:30 UTC
customer issue, and rejected by QE.  i am tentatively adding the JON 3.2 blocker .... to flag this.  this should be re-triaged at the 11/11/2013 BZ Triage meeting ...with input from GSS on the impact of this.

Comment 7 John Mazzitelli 2013-11-11 15:50:29 UTC
I think the problem is in the method "resolvePathRelativeToHomeDir".

Crazy thing is - there's more than one of these in more than one plugin! So I have a feeling this latest problem potentially exists for JBossAS 4, JBossAS 5, Tomcat, and Apache servers running on windows and configured without a drive letter!

See these:

===== JBOSS AS 4 PLUGIN:

org.rhq.plugins.jbossas.JBossASServerComponent.resolvePathRelativeToHomeDir(Configuration, String)

===== JBOSS AS 5 PLUGIN:

org.rhq.plugins.jbossas5.ApplicationServerComponent.resolvePathRelativeToHomeDir(String)

org.rhq.plugins.jbossas5.ApplicationServerDiscoveryComponent.resolvePathRelativeToHomeDir(Configuration, String)

org.rhq.plugins.jbossas5.ApplicationServerOperationsDelegate.resolvePathRelativeToHomeDir(Configuration, String)

===== TOMCAT PLUGIN:

org.jboss.on.plugins.tomcat.TomcatServerComponent.resolvePathRelativeToHomeDir(Configuration, String)

===== APACHE PLUGIN:

org.rhq.plugins.apache.ApacheServerComponent.resolvePathRelativeToServerRoot(Configuration, String)

Comment 8 John Mazzitelli 2013-11-11 15:54:21 UTC
I think the same kind of solution can be applied here as in the original patch. 

        if (!configDir.isAbsolute()) {

can be changed to

        if (!configDir.isAbsolute() && !configDir.isDirectory()) {

since, on Windows, if the only thing missing is the drive letter, that isDirectory should return true in this case (assuming the JVM current working directory's drive letter is the same - which we want to ensure anyway).

Comment 9 Larry O'Leary 2013-11-11 15:58:04 UTC
Yes. However, the only reason I didn't use isDirectory in my original suggested fix was because it was not clear what isDirectory would do with symbolic links or shortcuts on some platforms. But perhaps that was just paranoia.

Comment 10 John Mazzitelli 2013-11-11 16:15:41 UTC
(In reply to Larry O'Leary from comment #9)
> Yes. However, the only reason I didn't use isDirectory in my original
> suggested fix was because it was not clear what isDirectory would do with
> symbolic links or shortcuts on some platforms. But perhaps that was just
> paranoia.

Ran the following test - in short, isDirectory returns true even for relative path symlinks:

$ cat Tmp.java
import java.io.*;
public class Tmp {
   public static void main(String[] args) {
      File file = new File("mazzwashere");
      System.out.println("file: " + file);
      System.out.println("abs-path: " + file.getAbsolutePath());
      System.out.println("is-absolute: " + file.isAbsolute());
      System.out.println("exists: " + file.exists());
      System.out.println("is-dir: " + file.isDirectory());
   }
}

$ ls -ld mazzwashere
lrwxrwxrwx 1 mazz mazz 3 Nov 11 11:10 mazzwashere -> foo

$ java Tmp
file: mazzwashere
abs-path: /home/mazz/tmp/mazzwashere
is-absolute: false
exists: true
is-dir: true

Comment 11 John Mazzitelli 2013-11-11 16:20:02 UTC
of course, this change would have to assume all paths being processed ARE directories that actually exist. If the path being used isn't created yet or isn't a directory, this doesn't do what I want.

Similarily, if we just use .exists() - we assume the path already exists, or, again, it won't do what we want.

This was OK in the original patch because the run.jar should always exist.

I'll have to look more deeply at the callers of these methods to see if we can assume things like "it always exists" or "its always an existing directory".

Comment 12 John Mazzitelli 2013-11-11 22:45:02 UTC
git commit to master: aab2317

want to do more testing before pushing to release/jon3.2.x branch

Comment 13 John Mazzitelli 2013-11-12 17:08:08 UTC
I ran tests on a Windows 2008 machine and all looks to be working now. I will commit to the release/3.2.x branch shortly

Comment 14 John Mazzitelli 2013-11-12 17:12:32 UTC
(In reply to John Mazzitelli from comment #13)
> I ran tests on a Windows 2008 machine and all looks to be working now. I
> will commit to the release/3.2.x branch shortly

git commit to release/3.2.x: 50324de

Comment 15 Simeon Pinder 2013-11-19 15:48:26 UTC
Moving to ON_QA as available for testing with new brew build.

Comment 16 Simeon Pinder 2013-11-22 05:13:53 UTC
Mass moving all of these from ER6 to target milestone ER07 since the ER6 build was bad and QE was halted for the same reason.

Comment 17 Radim Hatlapatka 2013-11-26 13:36:50 UTC
Verified with JON 3.2.0.ER7 and EAP 5.2.0


Note You need to log in before you can comment on or make changes to this bug.