It's all about the answers!

Ask a question

Get Pkg by selecting elements


Pedro Capelotti (11) | asked Oct 31 '23, 9:39 a.m.

When trying to get the package from selected element by:

IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();

IRPPackage pkg = (IRPPackage) app.getSelectedElement();


I got the error:

class com.telelogic.rhapsody.core.RPClass cannot be cast to class com.telelogic.rhapsody.core.IRPPackage (com.telelogic.rhapsody.core.RPClass and com.telelogic.rhapsody.core.IRPPackage are in unnamed module of loader 'app')


Comments
Ralph Schoon commented Oct 31 '23, 12:05 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Please read How should I ask a question in the Forum if I want to receive useful answers? and ask a question. Refine your question.


Technically, the error means you do not get a class that implements IRPPackage, so you can't do the cast. Assuming that you talk about a Java API, you would have to test with instanceof before you cast. 
 

Be the first one to answer this question!


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.