Byteman with JBoss AS 7

Jooho Lee(Jay)
JBoss Technical Engineer
Agenda
●

Configure JBoss AS 7 for Byteman
–
–

Add Byteman Agent

–
●

Download Byteman
Add Byteman Environment

Test Sam...
Configure JBoss AS 7
●

Test Environment
–

EAP 6.1 (JBoss AS 7.2)

–

Byteman 2.1.3

–

Standalone Mode
Configure JBoss AS 7
●

Download Byteman
–

●

●

http://www.jboss.org/byteman/downloads

BYTEMAN_HOME=/home/jooho/Applica...
Configure JBoss AS 7
●

Add Byteman Agent / Environment
–

Edit EAP_HOME/bin/standalone.conf

–

Add bold text following :...
Configure JBoss AS 7
●

Byteman Agent

The agent reads byteman scripts when the application is launched and applies the ru...
Configure JBoss AS 7
●

Environment
–

org.jboss.byteman.transform.all

This environment prop is set then the agent will a...
Test Sample
●

Sample Web Application
package org.jhouse.test;
public class Helloworld {

}

public String sayHello(String...
Test Sample
●

Sample script(test.btm)
–

Description : When sayHello(String name) in
org.jhouse.test.Helloworld class is ...
Test Sample
Result Byteman Rule Log :
[stdout] (http-/127.0.0.1:8080-1) Rule.execute called for test1_0 ==>
[stdout] (http...
Upcoming SlideShare
Loading in …5
×

Byteman with as 7 20130925

829 views

Published on

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
829
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
7
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Byteman with as 7 20130925

  1. 1. Byteman with JBoss AS 7 Jooho Lee(Jay) JBoss Technical Engineer
  2. 2. Agenda ● Configure JBoss AS 7 for Byteman – – Add Byteman Agent – ● Download Byteman Add Byteman Environment Test Sample – Sample script – Check Byteman script – Demo –
  3. 3. Configure JBoss AS 7 ● Test Environment – EAP 6.1 (JBoss AS 7.2) – Byteman 2.1.3 – Standalone Mode
  4. 4. Configure JBoss AS 7 ● Download Byteman – ● ● http://www.jboss.org/byteman/downloads BYTEMAN_HOME=/home/jooho/Applications/Pro dGit/product-distributions/byteman Structure of Directory – my-script folder is created by me
  5. 5. Configure JBoss AS 7 ● Add Byteman Agent / Environment – Edit EAP_HOME/bin/standalone.conf – Add bold text following : export BYTEMAN_HOME=/home/jooho/Applications/ProdGit/product-distributions/byteman if [ "x$JAVA_OPTS" = "x" ]; then JAVA_OPTS="-Xms1303m -Xmx1303m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true" JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true" JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.byteman.transform.all -javaagent:$ {BYTEMAN_HOME}/lib/byteman.jar=script:${BYTEMAN_HOME}/my-scripts/test.btm,boot:$ {BYTEMAN_HOME}/lib/byteman.jar,listener:true"
  6. 6. Configure JBoss AS 7 ● Byteman Agent The agent reads byteman scripts when the application is launched and applies the rules to any code which matches a rule in the supplied scripts. ● -javaagent options: – script:scriptfile where scriptfile is a path to a file containing Byteman rules. This option causes the agent to read the rules in scriptFile and apply them to subsequently loaded classes. Multiple script arguments may be provided to ensure that more than one rule set is installed. It is possible to start the agent with no initial script arguments but this only makes sense if the listener option is supplied with value true. – listener:boolean where boolean is either true or false. This option causes the agent to start a listener thread at startup. The listener can be talked to using the bmsubmit script, either to provide listings of rule applications performed by the agent or to dynamically load, reload or unload rules. Loading or reloading of a rule causes any matching classes which have already been loaded into the JVM to be retransformed, inserting a trigger call for the newly loaded rules into their target methods. Unloading a rule causes trigger code to be removed from any matching classes. – boot:jarfile where jarfile is a path to to a jar file to be added to the JVM bootstrap class path. This option provides a similar facility to the sys option but it ensures that the classes contained in the jar file are loaded by the bootstrap class loader. This is only significant when rules try to inject code into JVM classes which are loaded by the bootstrap class loader (which is a parent of the system loader).
  7. 7. Configure JBoss AS 7 ● Environment – org.jboss.byteman.transform.all This environment prop is set then the agent will allow rules to be injected into methods of classes in the java.lang hierarchy. (Note that this will require the Byteman jar to be installed in the bootstrap classpath using the boot: option to the -javaagent JVM command line argument.)
  8. 8. Test Sample ● Sample Web Application package org.jhouse.test; public class Helloworld { } public String sayHello(String name){ System.out.println("Hello "+ name); return "Hello "+ name; package org.jhouse.test; } Import .... /** * Servlet implementation class CallTest */ @WebServlet("/CallTest") public class CallTest extends HttpServlet { ..... .... protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Helloworld hw = new Helloworld(); hw.sayHello("JHOUSE"); } }
  9. 9. Test Sample ● Sample script(test.btm) – Description : When sayHello(String name) in org.jhouse.test.Helloworld class is called, the name will print out like “Name : $1”. RULE test1 CLASS org.jhouse.test.Helloworld METHOD sayHello(String) AT ENTRY IF true DO traceln("Name : "+$1) ENDRULE
  10. 10. Test Sample Result Byteman Rule Log : [stdout] (http-/127.0.0.1:8080-1) Rule.execute called for test1_0 ==> [stdout] (http-/127.0.0.1:8080-1) test1 execute ==> Entry sayHello() method [stdout] (http-/127.0.0.1:8080-1) JHOUSE JHOUSE ==> Syste.out.println() in sayHello() [stdout] (http-/127.0.0.1:8080-1) Hello JHOUSE

×