2 Replies Latest reply on Mar 21, 2013 6:04 AM by Andrew Winter

    Add module via Management API in AS 7.2

    Andrew Winter Newbie

      Hi all


      I know the CLI has been updated in AS 7.2 / EAP 6.1.0 to support adding modules. Does anyone know if the native management API (jboss-as-controller-client) also supports adding modules? If so, are there any docs or sample code showing how to do this?





        • 1. Re: Add module via Management API in AS 7.2
          Jay SenSharma Master



              No, I do not think Creation of Module is possible via   Management API.


              However you can use CLI based java API to achieve the same:



          import java.io.IOException;
          import java.util.Map;
          import org.jboss.as.cli.CommandContext;
          import org.jboss.as.cli.CommandContextFactory;
          import org.jboss.as.cli.CommandLineException;
           public class ModuleAdd
             public static void main(String[] args) throws CommandLineException, IOException
                String host = "localhost";
                int port = 9999;
                ModuleAdd moduleAdd=new ModuleAdd();
                CommandContext ctx = CommandContextFactory.getInstance().newCommandContext("admin","admin123".toCharArray());
                ctx.connectController(host, port);
                 public void createSecurityDoModuleAdd(CommandContext ctx)
                   System.out.println("Setting up the module with CLI");
                   try {               
                          String command="module add --name=aaa.bbb --resources=/NotBackedUp/DELETE/ojdbc6.jar --dependencies=javax.api,javax.transaction.api";
                   catch (CommandLineException e) 




            For example when you open a Terminal and export JBOSS_HOME in the terminal  and then when you run the above code you wil see a Module is added in JBoss AS7.1.3  or higher version of it as following:





          └── bbb

              └── main

                  ├── module.xml

                  └── ojdbc6.jar



          module.xml as following:


          <?xml version="1.0" ?>
          <module xmlns="urn:jboss:module:1.1" name="aaa.bbb">
                  <resource-root path="ojdbc6.jar"/>
                  <module name="javax.api"/>
                  <module name="javax.transaction.api"/>
          1 of 1 people found this helpful
          • 2. Re: Add module via Management API in AS 7.2
            Andrew Winter Newbie

            Thanks for the tip, Jay. Having to rely on the filesystem isn't ideal but it's a good-enough workaround for me for now.