2014-02-17 42 views
0

我已經安裝工作燈搜索機票示例應用程序在Eclipse和工作燈6.1.from http://ibm.co/1oJaz71工作燈搜索機票示例應用程序,推送通知發出

我按照這個論壇上http://bit.ly/1kOPveN您的指令上創建一個Sender ID和API密鑰谷歌開發人員網站:http://developer.android.com/google/gcm/gs.html

我已經在application-descriptor.xml文件中插入了senderID和API密鑰,如下所示:(爲了本文的目的,我用「...」替換了實際值)。

<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 
+0

在我看來,使這個示例應用程序工作的關鍵數據點是: – Lennart

+0

使這個示例應用程序在Worklight Developer Edition 6.1中工作的關鍵點是:1)在http://developer.android中創建項目.com/google/gcm/gs.html並獲取您的GCM發件人ID和API密鑰以及將Google Cloud Messaging for Android設置爲ON。 2)在您的應用程序的application-descriptor.xml文件中插入一個。但是,這一切,因爲我一直在Android模擬器中運行示例時收到錯誤消息「無法註冊推送通知...」。 – Lennart

+0

PS,錯誤日誌顯示以下消息:Http請求失敗:org.apache.http.conn.HttpHostConnectException:連接到http:// localhost:9080被拒絕 – Lennart

回答