如何分析SAP UI5應用的undefined is not a function錯誤
Recently I meet with an annoying Javascript error “undefined is not a function” during my Fiori development. After debugging the framework code for several hours
, I finally find a more efficient way to find the exact source code which causes the trouble. I would like to share this small tip with you and hope it could help.
Issue: When I am doing test on my application on a local tomcat, I could only see an empty screen.
For sure there must be some Javascript error occurred.
Open Chrome console and I see one Uncaught TypeError: undefined is not a function as expected.
Unfortunately this error is raised in UI5 framework js “UIComponent.js”, after I click the hyperlink in the screenshot above, I am automatically navigated to this file, however I do completely not understand what has happened here, in function ( q, C, U, V ).
Then I press Ctrl+Alt+Shift+P to switch on debug by marking checkbox “Use Debug Sources”.
Refresh UI and now the debug resource, UIComponent-dbg.js is loaded instead. Since what I bad need is the context of this error, or callstack, so I set a breakpoint on catch statement, line 47. Relaunch application UI and breakpoint is triggered. I add variable e in Watch Expression:
Expand variable e in Watch Expressions and put the mouse to stack. The complete callstack is instantly displayed. The topmost callstack shows the error occurs in line 154, column 36 of file ConnectionManager-dbg.js:
Then I find the root cause here:
the variable service.serviceUrl is not a String but an object of URI which does not have a method named “indexOf”:
Conclusion
Although this error is raised in UI framework js file, it is however an absolute application issue: the url of OData is defined in Configuration.js file by application as metadata, and UI framework in the runtime will ask for it by calling some callback functions defined by application and then consume it. Framework will assume always a String for OData service url returned by application. After the following fix is done on application, the issue is fixed.
Any other alternative solution?
Later on I find another approach to find the position ( line 154, column 36 ) even without debugging.
I test my app with Firefox. To my surprise, it could directly display more detail about this error compared with Chrome: “j.serviceUrl.indexOf is not a function”.
The Firefox console shows this error occurs in sap-ui-core.js line 80
However I could not find any hit by searching “indexOf” within this file.
So I just again switch to Chrome and search serviceUrl.indexOf in Chrome instead, this time I get directly what I am looking for.
From this cause it seems that these two complementary powerful tool, Chrome and Firefox, could make our life as UI5 developer more easier.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2718730/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ThinkPHP函式提示錯誤function undefined的方法PHP函式FunctionUndefined
- 關於 SAP UI5 getSAPLogonLanguage is not a function 的錯誤訊息以及 API 版本的討論UIGoFunctionAPI
- SAP Fiori應用裡出現http request錯誤的原因分析HTTP
- SAP UI5 應用出現白屏的一些常見錯誤和分析方法分享試讀版UI
- 部署 SAP UI5 應用到 SAP BTP 時遇到的 fiori not found 錯誤訊息UI
- SAP Table function 執行報錯 feature not supported 該如何分析Function
- 部署 SAP UI5 應用到 SAP BTP 時遇到的 error retrieving MTA 錯誤訊息UIError
- SAP UI5 應用開發教程之一百零六 - 如何提高 SAP UI5 應用路由 url 的可讀性UI路由
- 易優CMS致命錯誤,聯絡技術支援:Call to undefined function eyPreventShell()-eyoucmsUndefinedFunction
- PHP報錯:Call to undefined function curl_init()PHPUndefinedFunction
- 織夢搜尋報錯undefined function TypeGetSunIDUndefinedFunction
- 如何修復 SAP UI5 aggregation with cardinality 0..1 相關的錯誤訊息UI
- 如何提取SAP UI5應用的技術資訊UI
- 使用 SAP WebIDE 將 SAP UI5 應用部署到 ABAP 系統時遇到的關於傳輸請求的錯誤WebIDEUI
- SAP UI5 應用 XML 檢視的載入邏輯分析UIXML
- 執行 valet 提示 sudo 問題和 undefined function Valet\collect () 錯誤的解決辦法UndefinedFunction
- SAP UI5 應用如何載入自定義 ThemeUI
- undefined reference to錯誤的解決方法Undefined
- SAP UI5 應用開發教程之四十五 - 如何在 SAP UI5 應用裡使用 jQuery 和原生的 DOM APIUIjQueryAPI
- 把 SAP UI5 應用部署到 SAP KymaUI
- 如何在阿里雲上執行SAP UI5應用阿里UI
- 本地開發的 SAP UI5 應用,部署到 ABAP 伺服器執行出錯的問題分析UI伺服器
- SAP UI5 應用的 OData 後設資料請求響應的解析原理分析UI
- SAP UI5應用裡的列表處理UI
- 如何使用 Chrome 除錯執行在手機上的 SAP UI5 Cordova 混合應用試讀版Chrome除錯UI
- 如何把SAP UI5應用部署到SAP雲平臺的Fiori Launchpad裡去UI
- 使用工具分析 SAP UI5 應用前端執行的效能問題UI前端
- SAP UI5 應用開發教程之五十九 - 如何在 SAP UI5 應用裡顯示世界地圖試讀版UI地圖
- SAP UI5應用入口App.controller.js是如何被UI5框架載入的?UIAPPControllerJS框架
- 使用Fiori Elements建立的SAP UI5應用,如何支援編輯功能UI
- SAP Fiori應用發生超時錯誤的一個可能原因
- SAP UI5 應用中的 sap.ui.require 使用場景UI
- SAP UI5 batch 請求的響應解析流程分析UIBAT
- 如何在桌面電腦端除錯執行在手機上的 SAP UI5 應用試讀版除錯UI
- Elasticsearch報Call to undefined xx makeAllSearchable()錯誤ElasticsearchUndefined
- SAP UI5 應用開發教程之一百零一 - SAP UI5 應用的 Locale 決定機制試讀版UI
- 使用SAP WebIDE給SAP UI5應用新增data sourceWebIDEUI
- SAP UI5 應用的中文亂碼問題UI