在我的門戶應用程序中試圖調用context.lookup()
調用的結果時,我得到ClassCastException
三次嘗試中的兩次來投擲不同的結果。無法繞過ClassCastException
經過一番研究,我認爲這個:http://wiki.sdn.sap.com/wiki/display/TechTSG/%28AS+Java%29+ClassCastException+Occurs+After+Lookup+Operation有答案,但它並沒有解釋如何執行這兩個步驟。
此代碼用於獲取的iView中的細節,從存儲在list
其路徑:
IiView transView1 = (IiView) context.lookup(list.get(i).toString());
但獲取工作集的細節時,是這樣的:
IPcdContext attrSet = (IPcdContext) context.lookup(list.get(i).toString());
我得到了ClassCastException
。任何幫助或解釋爲什麼我得到這個錯誤將不勝感激!
EDIT2:我回來從context.lookup目的是com.sapportals.portal.pcd.pcm.roles.PortalWorkset
,我無法找到的文檔。
什麼是確切的異常文本? – jtahlborn 2012-07-17 15:46:21
大概你會得到異常,因爲無論你從'context.lookup'返回的是不是'IPcdContext'。你應該把它作爲一個Object來捕獲,並執行'.getClass()。getName()'來找出你得到的結果。 – 2012-07-17 15:46:58