I want to deploy an ear file to wildfly-17.0.1 server using jboss-cli. I tried to execute the command using Java code but I'm always getting Error, here is my code:
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");
I'm always getting this error :
"failure-description" => "WFLYCTL0158: Operation handler failed: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0"