Search code examples
jbosscommand-line-interface

Is there a way to check before adding module to JBoss using CLI?


Is there a way to check module hasn't already been added before calling adding using JBoss CLI?

e.g.

module add --name=org.mysql --resources=/home/abc/drivers/mysql/MySQL5.jar



# Want to do similar check for module add
if (outcome != success) of /subsystem=datasources/jdbc-driver=org.mysql:read-resource
   # Add it...
end-if

Reason is trying to add a module that already exists causes an error.


Solution

  • When in domain mode, you can do that.

    Here's how you can check a module's existence:

    if (outcome != success) of /host=master/core-service=module-loading/:list-resource-loader-paths(module=your.module.name)
        echo install your.module.name ...   
        module add --name=your.module.name --dependencies=.. --resources=....jar
    else 
        echo module your.module.name already installed
    end-if