BotMill / fb-botmill

A Java framework for building bots on Facebook's Messenger Platform.
MIT License
72 stars 26 forks source link

Problem during deserialize message #55

Closed fritzZz closed 7 years ago

fritzZz commented 7 years ago

I configured the server instance and seems to work fine. I got the message but the deserialization goes in error:

What I'm doing wrong ?

My code:

` public class MyFbBotDefinitionClass extends AbstractFbBot { public void defineBehavior() {

    // Setting my tokens from Facebook (page token and validation token for webhook).
    FbBotMillContext.getInstance().setup("real_token", "real_validation_token");
    // Defining a bot which will reply with "Hello World!" as soon as I write "Hi"
    addActionFrame(new MessageEvent("Hi"),new MessageAutoReply("Hello World of Fluttr!"));

}

} `

Stacktrace

2017-01-30T12:58:48.827982+00:00 app[web.1]: 12:58:48.827 [http-nio-17732-exec-5] DEBUG c.a.botmill.fb.FbBotMillServlet - JSON input: {"object":"page","entry":[{"id":"683477205158863","time":1485781128667,"messaging":[{"sender":{"id":"1108634062596634"},"recipient":{"id":"683477205158863"},"timestamp":1485781128631,"message":{"mid":"mid.1485781128631:03b7a3eb69","seq":32271,"text":"ciao"}}]}]} 2017-01-30T12:58:48.830507+00:00 app[web.1]: 12:58:48.830 [http-nio-17732-exec-5] ERROR c.a.botmill.fb.FbBotMillServlet - Error during MessengerCallback parsing: 2017-01-30T12:58:48.830509+00:00 app[web.1]: java.lang.NullPointerException: null 2017-01-30T12:58:48.830510+00:00 app[web.1]: at co.aurasphere.botmill.fb.internal.util.json.IncomingMessageDeserializer.deserialize(IncomingMessageDeserializer.java:56) ~[fb-botmill-1.1.0.jar:na] 2017-01-30T12:58:48.830511+00:00 app[web.1]: at co.aurasphere.botmill.fb.internal.util.json.IncomingMessageDeserializer.deserialize(IncomingMessageDeserializer.java:44) ~[fb-botmill-1.1.0.jar:na] 2017-01-30T12:58:48.830512+00:00 app[web.1]: at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830512+00:00 app[web.1]: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830513+00:00 app[web.1]: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830514+00:00 app[web.1]: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830515+00:00 app[web.1]: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830515+00:00 app[web.1]: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830516+00:00 app[web.1]: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830517+00:00 app[web.1]: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830518+00:00 app[web.1]: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830518+00:00 app[web.1]: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830519+00:00 app[web.1]: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830520+00:00 app[web.1]: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830521+00:00 app[web.1]: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830522+00:00 app[web.1]: at com.google.gson.Gson.fromJson(Gson.java:887) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830522+00:00 app[web.1]: at com.google.gson.Gson.fromJson(Gson.java:852) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830523+00:00 app[web.1]: at com.google.gson.Gson.fromJson(Gson.java:801) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830526+00:00 app[web.1]: at com.google.gson.Gson.fromJson(Gson.java:773) ~[gson-2.7.jar:na] 2017-01-30T12:58:48.830526+00:00 app[web.1]: at co.aurasphere.botmill.fb.internal.util.json.JsonUtils.fromJson(JsonUtils.java:103) ~[fb-botmill-1.1.0.jar:na] 2017-01-30T12:58:48.830527+00:00 app[web.1]: at co.aurasphere.botmill.fb.FbBotMillServlet.doPost(FbBotMillServlet.java:201) ~[fb-botmill-1.1.0.jar:na] 2017-01-30T12:58:48.830528+00:00 app[web.1]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830528+00:00 app[web.1]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830529+00:00 app[web.1]: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830530+00:00 app[web.1]: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830531+00:00 app[web.1]: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830531+00:00 app[web.1]: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830532+00:00 app[web.1]: at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830533+00:00 app[web.1]: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830533+00:00 app[web.1]: at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830534+00:00 app[web.1]: at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830535+00:00 app[web.1]: at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830535+00:00 app[web.1]: at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830540+00:00 app[web.1]: at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830552+00:00 app[web.1]: at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830555+00:00 app[web.1]: at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830556+00:00 app[web.1]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102-cedar14] 2017-01-30T12:58:48.830556+00:00 app[web.1]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102-cedar14] 2017-01-30T12:58:48.830557+00:00 app[web.1]: at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.28.jar:8.0.28] 2017-01-30T12:58:48.830558+00:00 app[web.1]: at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102-cedar14]

The problem seems to be :

boolean isEcho = json.getAsJsonObject().get("is_echo").getAsBoolean();

in co.aurasphere.botmill.fb.internal.util.json.IncomingMessageDeserializer.deserialize(..) method

fritzZz commented 7 years ago

I tried to import the original source code (master) but when I receive the message I get only the following row in the server log : 2017-01-30T14:23:21.838745+00:00 heroku[router]: at=info method=POST path="/myfirstbotservlet" host=polar-reef-13963.herokuapp.com request_id=a8f568f8-3777-4453-b166-9eb0f401dfc3 fwd="173.252.90.125" dyno=web.1 connect=0ms service=877ms status=200 bytes=121

But no message has been processed. Why? How can I solve the problem? Do you suggest to wait the next version of the built library? I need to synchronize the library with maven (server side) during the deployment so I need the library from maven or I have to include the original source code in my project

fritzZz commented 7 years ago

I found also the release 1.2.0 but I've the same error, the bugfix was not included in this release. When you are planning to release this bugfix. The Hello World example is still not working!

aurasphere commented 7 years ago

Hi fritzZz!

Thank you for your feedback. This should be fixed with 1.2.1 release that I've already published on maven. It will be out as soon as the sync is done (this process usually takes some hours). Thank you for the patience!

aurasphere commented 7 years ago

Solved with #52 in version 1.2.1.