public void init() {
try {
int port=JimStarter.start();
log.info("IM service started by port "+port);
}
catch(Exception ex){
log.error("IM service start failed,error is "+ex.getMessage());
}
}
public class JimStarter {
public static int start() throws Exception {
PropKit.use("properties/jim.properties");
int port = PropKit.getInt("port");//启动端口
ImConfig.isStore = PropKit.get("is_store");//是否开启持久化;(on:开启,off:不开启)
ImConfig.isCluster = PropKit.get("is_cluster");//是否开启集群;
ImConfig imConfig = new ImConfig(null, port);
HttpServerInit.init(imConfig);
initSsl(imConfig);//初始化SSL;(开启SSL之前,你要保证你有SSL证书哦...)
//ImgMnService.start();//启动爬虫爬取模拟在线人头像;
imConfig.setImGroupListener(new GroupListener());//设置群组监听器,非必须,根据需要自己选择性实现;
ImServerStarter imServerStarter = new ImServerStarter(imConfig);
/*****************start 以下处理器根据业务需要自行添加与扩展,每个Command都可以添加扩展,此处为demo中处理**********************************/
HandshakeReqHandler handshakeReqHandler = CommandManager.getCommand(Command.COMMAND_HANDSHAKE_REQ, HandshakeReqHandler.class);
handshakeReqHandler.addProcessor(new HandshakeProcessor());//添加自定义握手处理器;
LoginReqHandler loginReqHandler = CommandManager.getCommand(Command.COMMAND_LOGIN_REQ, LoginReqHandler.class);
loginReqHandler.addProcessor(new LoginServiceProcessor());//添加登录业务处理器;
/*****************end *******************************************************************************************/
imServerStarter.start();
return port;
}
出错如下:
[DEBUG] 21:17:36.820 org.nutz.ioc.loader.combo.ComboIocLoader.printFoundIocBean(ComboIocLoader.java:226) - Found IocObject(mainLauncher) in AnnotationIocLoader(packages=[shuxin.epei.im])
[DEBUG] 21:17:36.820 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:223) - >> Make...'mainLauncher'<class shuxin.epei.im.MainLauncher>
[DEBUG] 21:17:36.820 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:65) - Save object 'mainLauncher' to [app]
[DEBUG] 21:17:36.821 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:76) - Load class shuxin.epei.im.MainLauncher without AOP
[DEBUG] 21:17:36.826 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:166) - Get 'conf'<class org.nutz.ioc.impl.PropertiesProxy>
[DEBUG] 21:17:37.125 org.jim.server.handler.ProtocolHandlerConfigurationFactory.parseConfiguration(ProtocolHandlerConfigurationFactory.java:94) - Configuring server_handler from server_handler.properties found in the classpath: jar:file:/C:/Users/shufu/.m2/repository/org/j-im/jim-server/2.2.0.v20180725-RELEASE/jim-server-2.2.0.v20180725-RELEASE.jar!/org/jim/server/handler/protocol_handler.properties
[DEBUG] 21:17:37.125 org.jim.server.handler.ProtocolHandlerConfigurationFactory.parseConfiguration(ProtocolHandlerConfigurationFactory.java:62) - Configuring server_handler from URL: jar:file:/C:/Users/shufu/.m2/repository/org/j-im/jim-server/2.2.0.v20180725-RELEASE/jim-server-2.2.0.v20180725-RELEASE.jar!/org/jim/server/handler/protocol_handler.properties
[DEBUG] 21:17:37.125 org.jim.server.handler.ProtocolHandlerConfigurationFactory.parseConfiguration(ProtocolHandlerConfigurationFactory.java:109) - Configuring server_handler from InputStream
[ERROR] 21:17:37.483 org.jim.server.handler.ProtocolHandlerManager.init(ProtocolHandlerManager.java:90) - io.github.lukehutch.fastclasspathscanner.MatchProcessorException: Multiple exceptions thrown of type: java.lang.NoSuchMethodError: org.apache.commons.lang3.StringUtils.replaceAll(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;. To see individual exceptions, call MatchProcessorException#getExceptions(), or call FastClasspathScanner#verbose() before FastClasspathScanner#scan().
[INFO ] 21:17:37.485 org.jim.server.ws.WsProtocolHandler.init(WsProtocolHandler.java:71) - wsServerHandler 初始化完毕...
[DEBUG] 21:17:37.500 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:85) - Remove object 'mainLauncher' from [app]
[ERROR] 21:17:37.502 org.nutz.boot.NbApp.execute(NbApp.java:219) - something happen!!
org.nutz.ioc.IocException: IocBean[mainLauncher] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:161)
at org.nutz.boot.NbApp.execute(NbApp.java:209)
at org.nutz.boot.NbApp.run(NbApp.java:178)
at shuxin.epei.im.MainLauncher.main(MainLauncher.java:36)
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.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/tio/server/AioServer
at org.jim.server.ImServerStarter.init(ImServerStarter.java:64)
at org.jim.server.ImServerStarter.<init>(ImServerStarter.java:40)
at org.jim.server.ImServerStarter.<init>(ImServerStarter.java:34)
at shuxin.epei.im.jim.JimStarter.start(JimStarter.java:31)
at shuxin.epei.im.MainLauncher.init(MainLauncher.java:26)
at shuxin.epei.im.MainLauncher$FM$init$5a5154d21bb7a73c1bc0e0f3494ec898.invoke(MainLauncher.java)
at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:180)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
... 12 more
Caused by: java.lang.ClassNotFoundException: org.tio.server.AioServer
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 more
[INFO ] 21:17:37.514 org.eclipse.jetty.server.AbstractConnector.doStop(AbstractConnector.java:332) - Stopped ServerConnector@25e063c9{HTTP/1.1,[http/1.1]}{127.0.0.1:8080}
[INFO ] 21:17:37.514 org.eclipse.jetty.server.session.HouseKeeper.stopScavenging(HouseKeeper.java:167) - node0 Stopped scavenging
[INFO ] 21:17:37.515 org.nutz.boot.starter.nutz.mvc.NbMvcLoading.depose(NbMvcLoading.java:54) - Nutz.Mvc[nutz] is deposing ...
[INFO ] 21:17:37.515 org.nutz.boot.starter.nutz.mvc.NbMvcLoading.depose(NbMvcLoading.java:70) - Nutz.Mvc[nutz] is down in 0ms
[INFO ] 21:17:37.521 org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:1020) - Stopped o.e.j.w.WebAppContext@49714039{/,[file:///C:/working/shuxin.epei/im/target/classes/static/, jar:file:/C:/Users/shufu/.m2/repository/org/nutz/nutzboot-starter-swagger/2.3-SNAPSHOT/nutzboot-starter-swagger-2.3-SNAPSHOT.jar!/static/],UNAVAILABLE}
[INFO ] 21:17:37.543 org.quartz.core.QuartzScheduler.shutdown(QuartzScheduler.java:666) - Scheduler NutzbootScheduler_$_NON_CLUSTERED shutting down.
[INFO ] 21:17:37.543 org.quartz.core.QuartzScheduler.standby(QuartzScheduler.java:585) - Scheduler NutzbootScheduler_$_NON_CLUSTERED paused.