Execute Commands Examples

The execute-commands goal allows you to execute commands, in the CLI format, on the running JBoss Application Server.

Execute commands

The example below shows how to add a debug logger with a debug log file:

<project>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.9.Final</version>
                <configuration>
                    <execute-commands>
                        <commands>
                            <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
                            <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
                        </commands>
                    </execute-commands>
                </configuration>
            </plugin>
            ...
        </plugins>
        ...
    </build>
...
</project>

Execute commands from CLI scripts

The example below shows how to execute commands from a CLI script:

<project>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.9.Final</version>
                <configuration>
                    <execute-commands>
                        <scripts>
                            <script>config.cli</script>
                        </scripts>
                    </execute-commands>
                </configuration>
            </plugin>
            ...
        </plugins>
        ...
    </build>
...
</project>

Example of a CLI script to set the transaction timeout to 600 seconds.

batch
#set default transaction timeout
/subsystem=transactions :write-attribute(name=default-timeout, value=600)
#...
# Execute and reload
run-batch
:reload