rampatra / jbot

Make Slack and Facebook Bots in Java.
GNU General Public License v3.0
1.2k stars 352 forks source link

Error invoking controller - java.lang.reflect.InvocationTargetException: null #79

Open nicolaschiong opened 6 years ago

nicolaschiong commented 6 years ago

Hello, I've been stuck with this error for days.

It seems that the WebSocketSession is null.

Session StandardWebSocketSession[id=0, uri=null]

Session StandardWebSocketSession[id=0, uri=null]
Event   com.gideon.integration.handler.slack.model.Event@643d19a6
2017-10-24 13:16:50.810 ERROR 4808 --- [ient-SecureIO-1] c.gideon.integration.handler.slack.Bot   : Error invoking controller: 

java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
    at com.gideon.integration.handler.slack.Bot.invokeMethods(Bot.java:319) [classes/:na]
    at com.gideon.integration.handler.slack.Bot.handleTextMessage(Bot.java:190) [classes/:na]
    at com.gideon.integration.handler.slack.BotWebSocketHandler.handleTextMessage(BotWebSocketHandler.java:32) [classes/:na]
    at org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43) [spring-websocket-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.socket.handler.WebSocketHandlerDecorator.handleMessage(WebSocketHandlerDecorator.java:75) [spring-websocket-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleMessage(LoggingWebSocketHandlerDecorator.java:56) [spring-websocket-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:110) [spring-websocket-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$000(StandardWebSocketHandlerAdapter.java:42) [spring-websocket-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:81) [spring-websocket-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:78) [spring-websocket-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:394) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:495) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:294) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:133) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:95) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameClient.resumeProcessing(WsFrameClient.java:209) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameClient.access$300(WsFrameClient.java:31) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.doResumeProcessing(WsFrameClient.java:186) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:163) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.WsFrameClient$WsFrameClientCompletionHandler.completed(WsFrameClient.java:148) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WrapperFuture.complete(AsyncChannelWrapperSecure.java:465) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$ReadTask.run(AsyncChannelWrapperSecure.java:333) [tomcat-embed-websocket-8.5.16.jar:8.5.16]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_131]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_131]
Caused by: java.lang.NullPointerException: null
    at com.gideon.integration.handler.slack.config.SlackBot.onReceiveDM(SlackBot.java:60) ~[classes/:na]
    ... 29 common frames omitted
ajohnsonz commented 6 years ago

I'm having the same problem, I think it's because in SlackDao.class it connects to the RTM with the following line:

ResponseEntity<RTM> response = restTemplate.getForEntity(rtmUrl, RTM.class, slackToken);

Which does a GET request, but the Slack API has been updated and only accepts POST requests. I am planning on fixing this locally for myself, but will create a pull request if it works.

mndominguez commented 6 years ago

@ajohnsonz were you able to fix this?

ajohnsonz commented 6 years ago

Hi @mndominguez yeah I got it working for me - but I made a ton of changes in one go and was never 100% sure exactly what bit fixed it for me. You can see my changes here:

https://github.com/rampatra/jbot/pull/80/commits

Hopefully it points you in the right direction!