gpt4 book ai didi

java - 如何从 java 代码在 jboss cli 中启动嵌入式服务器?

转载 作者:行者123 更新时间:2023-11-30 10:42:30 24 4
gpt4 key购买 nike

我想检查一些 cli 命令是否在 java 中有效。我无法使用当前正在运行的配置文件。此外,我根本无法使用正在运行的 Wildfly,因为我必须时不时地重新加载。

所以我想使用offline-cli(带有嵌入式服务器的cli)

我在做什么:

使用 org.jboss.as.cli.scriptsupport.CLI 连接到 CLi

CLI cli = CLI.newInstance();
cli.connect("127.0.0.1",9990,"admin","admin".toCharArray());

通过 cli.cmd 启动嵌入式服务器

cli.cmd("embed-server --server-config=standalone.xml --std-out=discard");

但是除了我永远等待这个命令完成(?)之外,什么也没有发生。

我注意到的一件事是,在将我的应用程序 configuration-management.war 部署到 wildfly 之后,状态更改为“已部署”。但是随后,服务无法启动。我没有太在意它,因为在那之后我可以看到我的应用程序的输出。也许这与它有关?

2016-06-29 15:59:55,333 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 83) WFLYUT0021: Registered web context: /configuration

2016-06-29 15:59:55,364 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0016: Replaced deployment "configuration-management.war" with deployment "configuration-management.war"

2016-06-29 15:59:55,364 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) WFLYCTL0183: Service status report

WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."configuration-management.war".POST_MODULE



2016-06-29 16:00:29,530 INFO [stdout] (default task-1) this is mine!

我的 mozilla firefox 左上角只有那个死神的小纺车,表明我还在等待回应。

有什么提示吗?

最佳答案

当您启动嵌入式服务器时,它不会启动任何接口(interface)。这包括管理界面。看起来脚本支持不允许嵌入式 CLI。你可以 file a feature request不过还是支持一下。

不过,您可以使用 CLI CommandContext API 来实现这一点。

final CommandContext commandContext = CommandContextFactory.getInstance().newCommandContext();
commandContext.handle("embed-server --jboss-home=/path/to/wildfly-10.0.0.Final");
commandContext.handle(":read-resource");
commandContext.handle("stop-embedded-server");

请注意一些命令,如 module add,也需要设置 jboss.home.dir 系统属性。

关于java - 如何从 java 代码在 jboss cli 中启动嵌入式服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38102375/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com