我正在通过cloudera-manager-api获得集群.
我正在使用Maven shade-plugin.
还有一个与空指针异常有关的问题,但这并不能解决我的特定问题.它看起来像一个依赖问题,因为如果我在我的IDE中运行该应用程序它工作正常.
当我运行自打包的jar时,它会失败,我可能会缺少什么依赖?
来源如下
String host = HOST_PREFIX + args[0];
String command = args[1];
RootResourceV10 apiRoot = new ClouderaManagerClientBuilder()
.withHost(host).withPort(7180)
.withUsernamePassword(ADMIN, ADMIN).build().getRootV10();
if (apiRoot == null) {
System.exit(0);
}
ClustersResourceV10 clusterResource = apiRoot.getClustersResource();
try {
if (command.equals(START)) {
System.out.println("starting..");
ApiCommand cmd = apiRoot.getClustersResource().startCommand(
"cluster"
);
while (cmd.isActive()) {
cmd = apiRoot.getCommandsResource()
.readCommand(cmd.getId());
}
} else {
System.out.println("stopping..");
ApiCommand cmdstop = apiRoot.getClustersResource().stopCommand(
"cluster"
);
while (cmdstop.isActive()) {
cmdstop = apiRoot.getCommandsResource().readCommand(
cmdstop.getId());
}
}
} catch (NullPointerException e) …Run Code Online (Sandbox Code Playgroud)