【问题标题】:How to deploy an EAR file to wildfly-17.0.1 server with jboss-cli command using Java code如何使用 Java 代码使用 jboss-cli 命令将 EAR 文件部署到 wildfly-17.0.1 服务器
【发布时间】:2020-02-04 21:09:27
【问题描述】:

我想使用 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"

【问题讨论】:

    标签: java wildfly jboss-cli


    【解决方案1】:

    core 实用程序是 wildfly-maven-plugin 的一部分,可用于以编程方式部署内容。这可能比反射更友好一些。

    【讨论】:

    • 感谢您的回答,但我需要使用反射,我需要修复此错误
    猜你喜欢
    • 2015-03-12
    • 1970-01-01
    • 2015-01-16
    • 2013-05-26
    • 2015-10-03
    • 2017-03-25
    • 1970-01-01
    • 2011-03-08
    • 1970-01-01
    相关资源
    最近更新 更多