Byteman integration for Arquillian
Java Shell Batchfile
Failed to load latest commit information.
.github Introduces templates for GH issues and PRs Oct 26, 2016
.mvn/wrapper Adds mvn wrapper Oct 18, 2016
.gitignore ARQ-348 Add Initial Byteman support Jan 19, 2012
pom.xml [maven-release-plugin] prepare for next development iteration Sep 1, 2016

Byteman Integration for the Arquillian Project

Mocking 2.0, Runtime bytecode manipulation in Integration tests.


@BMRule and @BMRules can be placed on both Class and Method level in the TestClass.

The given rules will be active during BeforeClass or Before to AfterClass or After.

                name = "Throw exception on success", targetClass = "StatelessManagerBean", targetMethod = "forcedClassLevelFailure", 
                action = "throw new java.lang.RuntimeException()")
public class BytemanFaultInjectionTestCase {

    public static Archive<?> createDeployment() {
        return ShrinkWrap.create(WebArchive.class)
                .addClasses(StatelessManager.class, StatelessManagerBean.class);

    @EJB(mappedName = "java:module/StatelessManagerBean")
    private StatelessManager bean;

    @Test(expected = EJBException.class)
            name = "Throw exception on success", targetClass = "StatelessManagerBean", targetMethod = "forcedMethodLevelFailure", 
            action = "throw new java.lang.RuntimeException()")
    public void shouldBeAbleToInjectMethodLevelThrowRule()
        Assert.assertNotNull("Verify bean was injected", bean);

Required dependencies




<extension qualifier="byteman">
  <property name="autoInstallAgent">true</property>
  <property name="agentProperties">org.jboss.byteman.verbose=true</property>
  • autoInstallAgent (default false) If true the extension will attempt to install the Byteman Agent in the target Container runtime. If false it assumes the Byteman Agent is manually installed. autoInstallAgent requires tools.jar on the container classpath to perform the installation.

  • agentProperties Additional properties to use when auto installing the Byteman Agent. See the Byteman documentation for more details.

How to run the tests

As we are using Arquillian Chameleon, it's very easy to run the tests against different containers. To see the comprehensive list of what is supported out-of-the-box check here.

To run test against different version of WildFly only change chameleonTarget like follow:

$ mvn test -Darq.container.chameleon.configuration.chameleonTarget="wildfly:10.1.0.Final:managed"

If you have not provided chameleonTarget then it will take default value provided in your arquillian.xml.

While running the tests from an IDE, variable ${path.tools_jar} in arquillian.xml is not defined, as it's only defined in Maven build. Thus the execution results with NoClassDefFoundError. One possible way to overcome this problem is to hardcode Byteman settings in arquillian.xml pointing to the tools.jar file from your JDK. See commented out section in arquillian.xml.

To run the tests against the remote container make sure that you started your server with following VM arguments:,org.jboss.byteman -Xbootclasspath/a:${path.tools_jar}

If you want to do this from Eclipse IDE, go to "Edit Launch Configuration" of your server, append above parameter in VM arguments before you start.


When using autoInstallAgent with application server such as WildFly, the package has to be exposed as a system package and tools.jar added to the bootstrap classpath.

<property name="javaVmArguments">,org.jboss.byteman -Xbootclasspath/a:${path.tools_jar}</property>