springboot+storm集成打包部署问题
mafei6827 opened this issue · 4 comments
请问下springboot+storm集成后,用什么工具打包,我用Springboot打包后,storm执行提示找不到主函数。
你好!maven直接打包。提交拓扑的命令由buildStormCmd.java生成。依赖的jars会在mvn package的时候自动提取到target/libs。
我将target/libs目录下的相关jar包拷贝到storm集群nimbus节点(基于docker-compose搭建的集群)的 /apache-storm-1.2.2/lib 目录下。
2019-02-18 03:47:43,086:INFO main (StormSubmitter.java:313) - Dependency Blob keys - jars : [] / artifacts : []
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.RuntimeException: Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.
at org.apache.storm.StormSubmitter.submitJarAs(StormSubmitter.java:473)
at org.apache.storm.StormSubmitter.submitTopologyInDistributeMode(StormSubmitter.java:322)
at org.apache.storm.StormSubmitter.submitTopologyAs(StormSubmitter.java:263)
at org.apache.storm.StormSubmitter.submitTopology(StormSubmitter.java:390)
at org.apache.storm.StormSubmitter.submitTopology(StormSubmitter.java:162)
at com.maxplus1.demo.storm.AppMain.remoteSubmit(AppMain.java:36)
at com.maxplus1.demo.storm.AppMain.Laugher(AppMain.java:27)
at com.maxplus1.DemoApplication.main(DemoApplication.java:19)
... 8 more
@sniperXue 根据提示Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.解决问题。
可以视实际情况修改脚本代码。
ok! 我解决了下面粘上我提交的解决代码!AppMain.java
/*集群方式下的提交*/
conf.setNumWorkers(stormProps.getTopologyWorkers());
conf.setMaxSpoutPending(stormProps.getTopologyMaxSpoutPending());
try {
//get nimbus client
Map stormConf = Utils.readStormConfig();
stormConf.putAll(conf);
Nimbus.Client client = NimbusClient.getConfiguredClient(stormConf).getClient();
//upload JAR
String localJar = "/data/StormDemo.jar";
String remoteJar = StormSubmitter.submitJar(stormConf, localJar);
//submit topology
client.submitTopology(stormProps.getTopologyName(), remoteJar, JSONValue.toJSONString(conf), builder.createTopology());
} catch (Exception e) {
String errorMsg = "can't deploy topology " + stormProps.getTopologyName() + ", " + e.getMessage();
System.out.println(errorMsg);
}