我想使用jboss-cli将ear文件部署到wildfly-17.0.1服务器。我尝试使用Java代码执行命令,但是我总是遇到错误,这是我的代码:
Object instance = ReflectionUtil.getClass("org.jboss.as.cli.CommandContextFactory").getMethod("getInstance").invoke(null);
ctx = instance.getClass().getMethod("newCommandContext",String.class,String.class,char[].class).invoke(instance,"localhost:"+server.getProperty(SERVER_PORT), server.getProperty(SERVER_USER),server.getProperty(SERVER_PWD).toCharArray());
m = ctx.getClass().getMethod("connectController");
m.setAccessible(true);
m.invoke(ctx);
execute(ctx, "deploy " + earPath + projectName + ".ear");
我总是遇到这个错误:
"failure-description" => "WFLYCTL0158: Operation handler failed: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0"