Bug 855926

Summary: Apache plug-in throws NoClassDefFoundError or UnsatisfiedLinkError when Augeas is enabled but library can not be read
Product: [JBoss] JBoss Operations Network Reporter: Larry O'Leary <loleary>
Component: Plugin -- ApacheAssignee: Lukas Krejci <lkrejci>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: unspecified    
Version: JON 3.1.0CC: lkrejci, myarboro, skondkar, tsegismo
Target Milestone: DR01   
Target Release: JON 3.2.1   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 855927 1058474 (view as bug list) Environment:
Last Closed: 2014-05-08 17:43:36 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: 855927, 1058474    
Bug Blocks:    

Description Larry O'Leary 2012-09-10 15:53:04 UTC
Description of problem:
If Augeas support is enabled for an Apache Web Server resource and the Augeas library is missing, an exception is thrown without an explanation. 

WARN  [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Failure during discovery for [Directory] Resources - failed after 86 ms.
java.lang.Exception: Discovery component invocation failed.
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:297)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'augeas': libaugeas.so: cannot open shared object file: No such file or directory
        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:164)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:237)
        at com.sun.jna.Library$Handler.<init>(Library.java:140)
        at com.sun.jna.Native.loadLibrary(Native.java:375)
        at com.sun.jna.Native.loadLibrary(Native.java:360)
        at net.augeas.jna.Aug.<clinit>(Unknown Source)
        at net.augeas.Augeas.<init>(Unknown Source)
        at net.augeas.Augeas.<init>(Unknown Source)
        at org.rhq.plugins.apache.ApacheServerComponent.isAugeasEnabled(ApacheServerComponent.java:1011)
        at org.rhq.plugins.apache.ApacheVirtualHostServiceComponent.isAugeasEnabled(ApacheVirtualHostServiceComponent.java:633)
        at org.rhq.plugins.apache.ApacheDirectoryDiscoveryComponent.discoverResources(ApacheDirectoryDiscoveryComponent.java:64)
        at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:293)



 WARN  [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Failure during discovery for [IfModule] Resources - failed after 0 ms.
java.lang.Exception: Discovery component invocation failed.
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:297)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.augeas.jna.Aug
        at net.augeas.Augeas.<init>(Unknown Source)
        at net.augeas.Augeas.<init>(Unknown Source)
        at org.rhq.plugins.apache.ApacheServerComponent.isAugeasEnabled(ApacheServerComponent.java:1011)
        at org.rhq.plugins.apache.ApacheVirtualHostServiceComponent.isAugeasEnabled(ApacheVirtualHostServiceComponent.java:633)
        at org.rhq.plugins.apache.ApacheIfModuleDiscoveryComponent.discoverResources(ApacheIfModuleDiscoveryComponent.java:53)
        at sun.reflect.GeneratedMethodAccessor46.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.rhq.core.pc.util.DiscoveryComponentProxyFactory$ComponentInvocationThread.call(DiscoveryComponentProxyFactory.java:293)
        ... 5 more



Version-Release number of selected component (if applicable):
3.1.0

How reproducible:
Always

Steps to Reproduce:
1. Import Apache server instance into inventory
2. Enable Augeas support from the Apache resource's Inventory > Connection Settings tab

If running on Linux:
3. Shut down the agent
4. Rename the <RHQ_AGENT_HOME>/lib/augeas directory to <RHQ_AGENT_HOME/lib/augeas.disabled
5. Start agent
  
Actual results:
Agent log will contain an warnings 
   java.lang.UnsatisfiedLinkError: Unable to load library 'augeas': libaugeas.so: cannot open shared object file: No such file or directory
   java.lang.NoClassDefFoundError: Could not initialize class net.augeas.jna.Aug

Expected results:
   The exception/error should show a message: Augeas is enabled in configuration but was not found on the system.

Additional info:
The cause of these unhandled exceptions is due to the exception type. We are explicitly catching all exceptions of type java.lang.Exception. However, these exceptions are of type java.lang.Error. We should either catch these specific errors an provide a meaningful message for each or catch java.lang.Throwable to catch all exceptions that could be generated during the isAugeasEnabled() call.

Comment 2 Lukas Krejci 2014-01-27 21:24:15 UTC
In master by means of BZ 1058474

Comment 3 Thomas Segismont 2014-01-29 15:08:02 UTC
Cherry-picked over to release/jon3.2.x

commit 80ab9efe5868ec5e12797a48166bbb3f251a8483
Author: Lukas Krejci <lkrejci>
Date:   Mon Jan 27 22:12:25 2014 +0100

    Bug 855926 - Apache plug-in throws NoClassDefFoundError or UnsatisfiedLinkError when Augeas is enabled but library can not be read
    
    Log meaningful messages on failure to find/link Augeas lib
    
    Catch NoClassDefFoundError and UnsatisfiedLinkError and report them
    appropriately when checking for presence of Augeas in Apache plugin.
    
    Also emit slightly more direct message if we do not support Augeas for
    given version of Apache.
    
    (cherry picked from commit f7f0011072dd56f1a081aa24351966656ff94f83)
    Signed-off-by: Thomas Segismont <tsegismo>

Comment 4 Simeon Pinder 2014-02-18 15:08:08 UTC
Moving to ON_QA as available for testing in the following brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=336752

Note: the installed version is still JON 3.2.0.GA by design and this represents part of the payload for JON 3.2.1 also known as cumulative patch 1 for 3.2.0.GA.  How this will be delivered to customers is still being discussed.

Comment 5 Sunil Kondkar 2014-02-20 14:35:44 UTC
Verified on JON 3.2.1 DR01 build (Build Number :c758688:4c03150)

Followed the steps. Agent log has below message:

2014-02-20 14:51:01,294 ERROR [ResourceDiscoveryComponent.invoker.daemon-1] (org.rhq.plugins.apache.ApacheServerComponent)- Augeas is enabled in configuration but was not found on the system.
java.lang.UnsatisfiedLinkError: Unable to load library 'augeas': libaugeas.so: cannot open shared object file: No such file or directory

Comment 6 Mike Foley 2014-05-08 17:43:36 UTC
JON 3.2.1 released week of 5/5/2014