0

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"
khouloud
  • 417
  • 4
  • 17

1 Answers1

0

There is a core utility as part of the wildfly-maven-plugin that can be used to programmatically deploy content. This would likely be a bit friendlier to use than reflection.

James R. Perkins
  • 16,800
  • 44
  • 60