Worklight Flight Ticket Sample App,推送通知问题

时间:2014-02-17 22:20:17

标签: android eclipse notifications ibm-mobilefirst

我在Eclipse和Worklight 6.1中安装了Worklight Flight Ticket示例应用程序。来自http://ibm.co/1oJaz71

我已在此论坛http://bit.ly/1kOPveN上按照您的说明在Google Developer网站上创建了senderID和API密钥:http://developer.android.com/google/gcm/gs.html

我已将senderID和API密钥插入application-descriptor.xml文件中,如下所示:(为了本帖的目的,我已将实际值替换为“...”)。

<android version="1.0">
    <worklightSettings include="true"/>
    <pushSender key="......." senderId="....."/>        
    <security>            
        <encryptWebResources enabled="false"/>
        <testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, 
          mp4, mp3"/>
        <publicSigningKey>Replace this text with the public key of the certificate with
            which you sign the APK. For details see the Worklight Developer's Reference Guide.  
        </publicSigningKey>            
    </security>
</android>

请注意:我没有插入我的,因为我在模拟器中运行并且没有在文档中看到任何要求。

现在当我在模拟器中运行应用程序时,它出现了,我得到以下弹出窗口:

注册推送通知失败   该应用程序将无法接收通知。   您的设备不支持GCM。设备没有com.google.android.gsf包。   如果您使用的是Android模拟器,请确保它具有Google API(Google Inc)。

现在,在Android SDK管理器中,我已经安装了Google API。

另外,当我点击弹出窗口中的OK按钮时,我很快会得到第二个弹出窗口,上面写着:

 Confirm. Do you allow Flight Ticket to send notification to you Cancel/OK.

我单击“确定”,然后很快再次出现第一个弹出窗口:

注册推送通知失败   该应用程序将无法接收通知。   您的设备不支持GCM。设备没有com.google.android.gsf包。   如果您使用的是Android模拟器,请确保它具有Google API(Google Inc)。

你如何建议我调试这个?

我附加了错误日志的一部分:

Listening for transport dt_socket at address: 10777
Launching worklight (WebSphere Application Server 8.5.5.0/wlp-1.0.3.20130524-0951) on Java HotSpot(TM) Client VM, version 1.7.0_45-b18 (en_US)
[AUDIT   ] CWWKE0001I: The server worklight has been launched.
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications. 
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://ADMINIB-3IAG8DV:10080/module_60_4_FlightTicket/
[AUDIT   ] CWWKZ0001I: Application module_60_4_FlightTicket started in 7.968 seconds.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://ADMINIB-3IAG8DV:10080/_MobileBrowserSimulator/
[AUDIT   ] CWWKZ0001I: Application _MobileBrowserSimulator started in 0.076 seconds.
[AUDIT   ] CWWKF0011I: The server worklight is ready to run a smarter planet.
[ERROR   ] FWLSE0099E: An error occurred while invoking procedure  [project module_60_4_FlightTicket]FTAdapter/HttpRequestFWLSE0100E:  parameters: [project module_60_4_FlightTicket]{
   "arr": [
      {
         "body": {
            "content": "oneWay=true&fromDate=1392526800000&toAirport=HKG&fromAirport=LHR&returnDate=1392526800000",
            "contentType": "application\/x-www-form-urlencoded; charset=UTF-8"
         },
         "headers": {
            "HOST": "localhost"
         },
         "method": "POST",
         "path": "\/flightticket\/service\/flights\/queryflights",
         "returnedContentType": "json"
      }
   ]
}
Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
FWLSE0101E: Caused by:  [project module_60_4_FlightTicket]org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refusedjava.lang.RuntimeException: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
    at com.worklight.adapters.http.HTTPConnectionManager.execute(HTTPConnectionManager.java:241)
    at com.worklight.adapters.http.HttpClientContext.doExecute(HttpClientContext.java:176)
    at com.worklight.adapters.http.HttpClientContext.execute(HttpClientContext.java:160)
    at com.worklight.adapters.http.HTTP.execRequest(HTTP.java:135)
    at com.worklight.adapters.http.HTTP.invoke(HTTP.java:124)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at com.worklight.integration.model.InvocationContext$DirectExecutorService.execute(InvocationContext.java:284)
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
    at com.worklight.integration.model.InvocationContext.submit(InvocationContext.java:138)
    at com.worklight.integration.model.InvocationContextManager.submitInvocation(InvocationContextManager.java:58)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.callProcedure(DataAccessServiceImpl.java:484)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.access$100(DataAccessServiceImpl.java:56)
    at com.worklight.integration.services.impl.DataAccessServiceImpl$4.execute(DataAccessServiceImpl.java:387)
    at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedureInternal(DataAccessServiceImpl.java:384)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedure(DataAccessServiceImpl.java:443)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedure(DataAccessServiceImpl.java:427)
    at com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation.invokeDynamicProcedure(JavaScriptIntegrationLibraryImplementation.java:125)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at org.mozilla.javascript.gen._integration_js_1._c_anonymous_10(/integration.js:95)
    at org.mozilla.javascript.gen._integration_js_1.call(/integration.js)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen.C_3A_5Ceclipsekepler_5Cmodule_60_4_FlightTicket_5Cadapters_5CFTAdapter_FTAdapter_impl_js_5._c_FlightsREST_getTripFlights_6(C%3A%5Ceclipsekepler%5Cmodule_60_4_FlightTicket%5Cadapters%5CFTAdapter/FTAdapter-impl.js:64)
    at org.mozilla.javascript.gen.C_3A_5Ceclipsekepler_5Cmodule_60_4_FlightTicket_5Cadapters_5CFTAdapter_FTAdapter_impl_js_5.call(C%3A%5Ceclipsekepler%5Cmodule_60_4_FlightTicket%5Cadapters%5CFTAdapter/FTAdapter-impl.js)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
    at org.mozilla.javascript.gen.C_3A_5Ceclipsekepler_5Cmodule_60_4_FlightTicket_5Cadapters_5CFTAdapter_FTAdapter_impl_js_5.call(C%3A%5Ceclipsekepler%5Cmodule_60_4_FlightTicket%5Cadapters%5CFTAdapter/FTAdapter-impl.js)
    at com.worklight.integration.js.JavaScriptManager.callFunction(JavaScriptManager.java:240)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:214)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:194)
    at com.worklight.integration.services.impl.AdapterManagerImpl.invokeFunction(AdapterManagerImpl.java:104)
    at com.worklight.integration.js.JavaScriptProcedureInvoker.invoke(JavaScriptProcedureInvoker.java:42)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at com.worklight.server.util.ProjectLocal$1RunnableWrapper.run(ProjectLocal.java:267)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at com.worklight.adapters.http.HTTPConnectionManager.execute(HTTPConnectionManager.java:239)
    ... 50 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
    ... 56 more

                                                                                                               com.worklight.common.log.filters.ErrorFilter
[ERROR   ] FWLSE0099E: An error occurred while invoking procedure  [project module_60_4_FlightTicket]FTAdapter/HttpRequestFWLSE0100E:  parameters: [project module_60_4_FlightTicket]{
   "arr": [
      {
         "body": {
            "content": "oneWay=true&fromDate=1392526800000&toAirport=HKG&fromAirport=LHR&returnDate=1392526800000",
            "contentType": "application\/x-www-form-urlencoded; charset=UTF-8"
         },
         "headers": {
            "HOST": "localhost"
         },
         "method": "POST",
         "path": "\/flightticket\/service\/flights\/queryflights",
         "returnedContentType": "json"
      }
   ]
}
Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
FWLSE0101E: Caused by:  [project module_60_4_FlightTicket]org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refusedjava.lang.RuntimeException: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
    at com.worklight.adapters.http.HTTPConnectionManager.execute(HTTPConnectionManager.java:241)
    at com.worklight.adapters.http.HttpClientContext.doExecute(HttpClientContext.java:176)
    at com.worklight.adapters.http.HttpClientContext.execute(HttpClientContext.java:160)
    at com.worklight.adapters.http.HTTP.execRequest(HTTP.java:135)
    at com.worklight.adapters.http.HTTP.invoke(HTTP.java:124)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at com.worklight.integration.model.InvocationContext$DirectExecutorService.execute(InvocationContext.java:284)
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
    at com.worklight.integration.model.InvocationContext.submit(InvocationContext.java:138)
    at com.worklight.integration.model.InvocationContextManager.submitInvocation(InvocationContextManager.java:58)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.callProcedure(DataAccessServiceImpl.java:484)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.access$100(DataAccessServiceImpl.java:56)
    at com.worklight.integration.services.impl.DataAccessServiceImpl$4.execute(DataAccessServiceImpl.java:387)
    at com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedureInternal(DataAccessServiceImpl.java:384)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedure(DataAccessServiceImpl.java:443)
    at com.worklight.integration.services.impl.DataAccessServiceImpl.invokeDynamicProcedure(DataAccessServiceImpl.java:427)
    at com.worklight.integration.js.JavaScriptIntegrationLibraryImplementation.invokeDynamicProcedure(JavaScriptIntegrationLibraryImplementation.java:125)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
    at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
    at org.mozilla.javascript.gen._integration_js_1._c_anonymous_10(/integration.js:95)
    at org.mozilla.javascript.gen._integration_js_1.call(/integration.js)
    at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
    at org.mozilla.javascript.gen.C_3A_5Ceclipsekepler_5Cmodule_60_4_FlightTicket_5Cadapters_5CFTAdapter_FTAdapter_impl_js_5._c_FlightsREST_getTripFlights_6(C%3A%5Ceclipsekepler%5Cmodule_60_4_FlightTicket%5Cadapters%5CFTAdapter/FTAdapter-impl.js:64)
    at org.mozilla.javascript.gen.C_3A_5Ceclipsekepler_5Cmodule_60_4_FlightTicket_5Cadapters_5CFTAdapter_FTAdapter_impl_js_5.call(C%3A%5Ceclipsekepler%5Cmodule_60_4_FlightTicket%5Cadapters%5CFTAdapter/FTAdapter-impl.js)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
    at org.mozilla.javascript.gen.C_3A_5Ceclipsekepler_5Cmodule_60_4_FlightTicket_5Cadapters_5CFTAdapter_FTAdapter_impl_js_5.call(C%3A%5Ceclipsekepler%5Cmodule_60_4_FlightTicket%5Cadapters%5CFTAdapter/FTAdapter-impl.js)
    at com.worklight.integration.js.JavaScriptManager.callFunction(JavaScriptManager.java:240)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:214)
    at com.worklight.integration.js.JavaScriptManager.invokeFunction(JavaScriptManager.java:194)
    at com.worklight.integration.services.impl.AdapterManagerImpl.invokeFunction(AdapterManagerImpl.java:104)
    at com.worklight.integration.js.JavaScriptProcedureInvoker.invoke(JavaScriptProcedureInvoker.java:42)
    at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
    at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
    at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at com.worklight.server.util.ProjectLocal$1RunnableWrapper.run(ProjectLocal.java:267)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:9080 refused
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at com.worklight.adapters.http.HTTPConnectionManager.execute(HTTPConnectionManager.java:239)
    ... 50 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
    ... 56 more

1 个答案:

答案 0 :(得分:0)

如果您使用的是Android模拟器,则需要选择支持推送通知功能的“Google API”。设置AVD时,需要选择该API级别。

您可以参考IBM Worklight 5.0.6.1 - Android notification does not reach either device or emulator了解详情。