0 Replies Latest reply on Aug 16, 2017 9:19 AM by jjfraney

    get started with cli scripting

    jjfraney

      I've searched the google net and wildfly docs for examples.  There are a couple examples for jboss AS7 and Rhino, but not any for wildfly 10 and Nashorn.  I've searched for examples by the cli client jar name (jboss-cli-client.jar), and also by CommandContextFactoryImpl (class not found exception).

       

      Class loader does not find CommandContextFactoryImpl....even though it is present in the jboss-cli-client.jar.   Any suggestions on how I can overcome this?

       

       

       

      Here is js script.

       

      var CLI = Java.type("org.jboss.as.cli.scriptsupport.CLI");

      var cli = CLI.newInstance();  // exception thrown here.

       

       

       

      I run the script this way: jjs -cp ~/opt/wildfly10/wildfly-10.1.0.Final/bin/client/jboss-cli-client.jar cli-script.js

       

      Exception in thread "main" java.lang.IllegalStateException: Unable to initialize command context.

        at org.jboss.as.cli.scriptsupport.CLI.initOfflineContext(CLI.java:262)

        at org.jboss.as.cli.scriptsupport.CLI.<init>(CLI.java:53)

        at org.jboss.as.cli.scriptsupport.CLI.newInstance(CLI.java:62)

        at jdk.nashorn.internal.scripts.Script$add.:program(add.js:2)

        at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:636)

        at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)

        at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:387)

        at jdk.nashorn.tools.Shell.apply(Shell.java:394)

        at jdk.nashorn.tools.Shell.runScripts(Shell.java:323)

        at jdk.nashorn.tools.Shell.run(Shell.java:169)

        at jdk.nashorn.tools.Shell.main(Shell.java:133)

        at jdk.nashorn.tools.Shell.main(Shell.java:112)

      Caused by: org.jboss.as.cli.CliInitializationException: Failed to load org.jboss.as.cli.impl.CommandContextFactoryImpl

        at org.jboss.as.cli.CommandContextFactory.getInstance(CommandContextFactory.java:43)

        at org.jboss.as.cli.scriptsupport.CLI.initOfflineContext(CLI.java:260)

        ... 11 more

      Caused by: java.lang.ClassNotFoundException: org.jboss.as.cli.impl.CommandContextFactoryImpl

        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

        at org.jboss.as.cli.CommandContextFactory.getInstance(CommandContextFactory.java:41)

        ... 12 more