[英]java.lang.NoSuchMethodError in netty-socketio server
I'm trying to start netty-socketio
server, and I can't trace origins of this exception. 我正在尝试启动
netty-socketio
服务器,但无法跟踪此异常的起源。 I have marked in stacktrace place where it may lead to the answer, so if anyone could provide explanation on this it will be much appreciated. 我在stacktrace处标记了它可能会导致答案的位置,因此,如果有人可以对此提供解释,将不胜感激。
public class SocketIoServer {
private Configuration cnf = new Configuration();
private SocketIOServer server;
public SocketIoServer() {
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(8081);
server = new SocketIOServer(config);
server.start();
}
}
When I initialize socket an Exception gets thrown. 当我初始化套接字时,将引发异常。 Here's context:
这是上下文:
Exception in thread "main" java.lang.IllegalArgumentException:
java.lang.reflect.InvocationTargetException
at com.corundumstudio.socketio.Configuration.<init>(Configuration.java:112)
at com.corundumstudio.socketio.SocketIOServer.<init>(SocketIOServer.java:66)
at SocketIoServer.<init>(SocketIoServer.java:17)
at Server.main(Server.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.corundumstudio.socketio.Configuration.<init>(Configuration.java:109)
... 8 more
This line in particular 特别是这条线
Caused by: java.lang.NoSuchMethodError:
com.fasterxml.jackson.databind.module.SimpleModule.setSerializerModifier(Lcom/fasterxml/jackson/databind/ser/BeanSerializerModifier;)Lcom/fasterxml/jackson/databind/module/SimpleModule;
at com.corundumstudio.socketio.protocol.JacksonJsonSupport.init(JacksonJsonSupport.java:316)
at com.corundumstudio.socketio.protocol.JacksonJsonSupport.<init>(JacksonJsonSupport.java:311)
at com.corundumstudio.socketio.protocol.JacksonJsonSupport.<init>(JacksonJsonSupport.java:304)
... 13 more
You have obviously a conflict of version of jackson-databind
in your project, indeed the class com.corundumstudio.socketio.protocol.JacksonJsonSupport
relies on the method SimpleModule#setSerializerModifier(BeanSerializerModifier mod)
which has been added since the version 2.2
so as it cannot find this method, it means that you have a version of jackson-databind
older than 2.2
in your classpath such that the method cannot be found. 您的项目中显然存在
jackson-databind
版本的冲突,实际上com.corundumstudio.socketio.protocol.JacksonJsonSupport
类依赖于方法SimpleModule#setSerializerModifier(BeanSerializerModifier mod)
,因为该方法自2.2
版本以来已添加找到此方法,这意味着您在类路径中拥有的jackson-databind
版本早于2.2
,因此找不到该方法。
Check all the jars that you have in your classpath and make sure that you have only one version of jackson-databind
corresponding to the version expected by netty-socketio
. 检查类路径中所有的jar,并确保只有对应于
netty-socketio
期望的版本的jackson-databind
版本。 For example assuming that you use the version 1.7.12
of netty-socketio
, the expected version of jackson-databind
is 2.7.4
as you can see here . 例如,假设您使用
netty-socketio
1.7.12
版本,则jackson-databind
的预期版本为2.7.4
,如此处所示 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.