Bug 855927

Summary: Apache plug-in throws NoClassDefFoundError or UnsatisfiedLinkError when Augeas is enabled but library can not be read
Product: [Other] RHQ Project Reporter: Larry O'Leary <loleary>
Component: PluginsAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED DUPLICATE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.4CC: hrupp, lkrejci
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 855926 Environment:
Last Closed: 2014-01-27 21:22:09 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: 855926    

Description Larry O'Leary 2012-09-10 15:54:03 UTC
+++ This bug was initially created as a clone of JON product Bug #855926 +++

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 1 Lukas Krejci 2014-01-27 21:22:09 UTC
Accidentally overlooked this one and committed the fix through BZ 1058474.

Closing this one as it won't be mentioned in the commit logs.

*** This bug has been marked as a duplicate of bug 1058474 ***