Bug 863502

Summary: EMS ConnectionFactory.discoverServerClasses can throw OutOfMemoryError
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: PluginsAssignee: Rémy Maucherat <rmaucher>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.2CC: hrupp, tsegismo
Target Milestone: ---   
Target Release: RHQ 4.9   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-26 04:31:03 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Description Flags
Addresses OutOfMemoryError in EMS
Search recursively for EMS connection classes in HOME/lib instead of HOME (HOME/server/lib on Tomcat 5.5) none

Description Elias Ross 2012-10-05 12:06:49 EDT
Created attachment 622290 [details]
Addresses OutOfMemoryError in EMS

I have a Tomcat installation with a lot of files in a server directory. So many files that it is an issue finding the server classes.

This is what I see.

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
        at java.nio.ByteBuffer.wrap(ByteBuffer.java:350)
        at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:137)
        at java.lang.StringCoding.decode(StringCoding.java:173)
        at java.lang.String.<init>(String.java:443)
        at java.lang.String.<init>(String.java:515)
        at java.io.UnixFileSystem.list(Native Method)
        at java.io.File.list(File.java:973)
        at java.io.File.listFiles(File.java:1051)
        at org.mc4j.ems.connection.ConnectionFactory.findFile(ConnectionFactory.java:241)
        at org.mc4j.ems.connection.ConnectionFactory.findFile(ConnectionFactory.java:246)
        at org.mc4j.ems.connection.ConnectionFactory.findFile(ConnectionFactory.java:246)
        at org.mc4j.ems.connection.ConnectionFactory.findFile(ConnectionFactory.java:235)
        at org.mc4j.ems.connection.ConnectionFactory.discoverServerClasses(ConnectionFactory.java:204)
        at org.jboss.on.plugins.tomcat.TomcatServerComponent.loadConnection(TomcatServerComponent.java:201)
        at org.jboss.on.plugins.tomcat.TomcatServerComponent.start(TomcatServerComponent.java:307)

The obvious improvement would be to catch the exception.

Patch is attached
Comment 1 Thomas Segismont 2013-07-01 09:25:08 EDT
How many files do you have in your server directory?

Which directory is it of the Tomcat server?

What kind of files are you storing there?
Comment 2 Elias Ross 2013-07-01 12:40:56 EDT
Probably tens or hundreds of thousands of files in a single directory. It was a directory that did not contain classes but data files.

I'm guessing this is not really a big issue but the plugin should not have been looking for classes in there.
Comment 3 Thomas Segismont 2013-07-03 08:06:40 EDT
Fixed in master 

commit faf0013f511894eb2c7b9ef14f87b5e87d657154
Author: Thomas Segismont <tsegismo@redhat.com>
Date:   Wed Jul 3 14:01:00 2013 +0200

Changed the libraryURI root: the plugin was looking for catalina jars from the CATALINA_HOME directory, instead of CATALINA_HOME/lib.

Now users can put any number of files in CATALINA_HOME, provided they're outside the lib directory.
Comment 4 Thomas Segismont 2013-07-03 11:07:27 EDT
Reverted. This needs to go through the EWS team
Comment 5 Thomas Segismont 2013-07-11 06:43:09 EDT
Created attachment 772164 [details]
Search recursively for EMS connection classes in HOME/lib instead of HOME (HOME/server/lib on Tomcat 5.5)
Comment 6 Rémy Maucherat 2013-07-11 09:45:48 EDT
The new patch is looking good, and can be backported if needed as it will certainly support Tomcat 5.5 as well. In case the functionality is really required in some cases.
commit	794d564b16b697870ca92040f27acbcdcad63522 in master
Comment 7 Heiko W. Rupp 2014-03-26 04:31:03 EDT
Bulk closing now that 4.10 is out.

If you think an issue is not resolved, please open a new BZ and link to the existing one.