While trying to cast the result of a context.lookup()
call in my portal application, I'm getting a ClassCastException
for two out of three attempts at casting different results.
After some research I think this: http://wiki.sdn.sap.com/wiki/display/TechTSG/%28AS+Java%29+ClassCastException+Occurs+After+Lookup+Operation holds the answer, but it doesn't explain really how to carry out the two steps.
This code works for fetching the details of an iView, from its path stored in list
:
IiView transView1 = (IiView) context.lookup(list.get(i).toString());
but when fetching details of a workset like this:
IPcdContext attrSet = (IPcdContext) context.lookup(list.get(i).toString());
I get a ClassCastException
. Any help or explanation as to why I get this error would be greatly appreciated!
edit: This is what the code is based on: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401?overridelayout=true
edit2: The object I get back from context.lookup is com.sapportals.portal.pcd.pcm.roles.PortalWorkset
which I can't find documentation on.