Java agent that detects file handle leak for WebSpere Application Server 8.5 (IBM JDK 1.6)
by Lao Wei(zrlw@sina.com) on Oct 01 21:19:00 GMT+8 2019
- after git clone the project, you should change java.home in pom.xml to your Oracle JDK's JRE directory.
- Maven - Update Project... - OK
- Run as - Maven build...
- in Main tab
Goals: install -e
checked 'Skip Tests' option - in JRE tab
runtime JRE: Oracle JRE (suggest Oracle JRE 1.8) - click run button, it will download needed jars from maven repositories.
- after Build Success, configure project's build path, set JRE System library to IBM JDK 1.6
- Project - Clean
- Project - Build Project
- Export - Jar file - only export src/main/java
- edit the exported jar, add such contents to META-INF/MANIFEST.MF
Premain-Class: org.kohsuke.file_leak_detector.AgentMain
Agent-Class: org.kohsuke.file_leak_detector.AgentMain
Main-Class: org.kohsuke.file_leak_detector.Main
Can-Redefine-Classes: true
Can-Retransform-Classes: true
Built-By: your-name
- uncompress asm6 & args4j jar to a temp directory from your local repository which can be found in project build path.
- merge org directory of asm6 & args4j from the temp directory into the exported jar.
- copy the exported jar to the machine which run the WebSphere Application Server.
- logon WAS administrator console, set Java virtual machine of the WebSpere Application Server to debug mode.
Detector Method A:
1. add -javaagent:<your-path>/<your-jar>=http=<your-port>,host=<ip-of-WAS-machine> in general JVM parameters of the WAS.
2. start WAS
check <websphere_profile_home>/<node>/logs/<server>/native_stderr.log for error.
Detector Method B:
logon the account which run WAS process, run command:
<WAS-java-bin-path>/java -jar <your-path>/<your-jar> <WAS-PID> http=<your-port>,host=<ip-of-WAS-machine>
now open your browser, open http://<ip-of-WAS-machine>:<your-port> to get detector result.