Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Get Pkg by selecting elements

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')

0 votes

Comments

 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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,940

Question asked: Oct 31 '23, 9:39 a.m.

Question was seen: 569 times

Last updated: Oct 31 '23, 12:05 p.m.

Confirmation Cancel Confirm