I'm not able with byteman 4.0.15 and JBoss EAP 7.3 to have an helper class in order to get connection from IronJacamar module, I've encountered a NoClassDefFoundException when my helper class try to get it.
here the btm, I've added IMPORT with the module name of ironjacamar Jboss Module
RULE WrappedDataSource getcnx
CLASS org.jboss.jca.adapters.jdbc.WrapperDataSource
IMPORT org.jboss.ironjacamar.jdbcadapters
METHOD getConnection()
HELPER org.jboss.byteman.ConnectionHelper
AT EXIT
IF true
DO traceConnection($!);
ENDRULE
Here my helper class (package named org.jboss.byteman and packaged in bytemanhelper-0.0.1-SNAPSHOT.jar):
package org.jboss.byteman;
import org.jboss.byteman.rule.Rule;
import org.jboss.byteman.rule.helper.Helper;
import org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8;
import java.sql.SQLException;
public class ConnectionHelper extends Helper {
protected ConnectionHelper(Rule rule) {
super(rule);
}
public void traceConnection(final Object connection) {
try {
System.out.println("Real connexion =" + ((WrappedConnectionJDK8)connection).getUnderlyingConnection());
} catch (SQLException e) {
e.printStackTrace();
}
}
}
I've added the following properties to JBoss EAP:
-Djboss.modules.system.pkgs=org.jboss.byteman -javaagent:/var/byteman-download-4.0.15/lib/byteman.jar=script:/var/bytemanrules.btm,sys:/var/bytemanhelper-0.0.1-SNAPSHOT.jar,sys:/var/byteman-download-4.0.15/contrib/jboss-modules-system/byteman-jboss-modules-plugin.jar,modules:org.jboss.byteman.modules.jbossmodules.JBossModulesSystem -Dorg.jboss.byteman.transform.all=true
But when traceConnection method is executing
((WrappedConnectionJDK8)connection).getUnderlyingConnection()
I've got a java.lang.NoClassDefFoundError: org/jboss/jca/adapters/jdbc/jdk8/WrappedConnectionJDK8 while this class is present in ironjacamar-jdbc-1.4.30.Final-redhat-00001.jar stored in JBoss Module org.jboss.ironjacamar.jdbcadapters.
Is there a way to intercept and handle JBoss module classes whit byteman rules?
Pierre