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

Get IChangeSetHandle from IChangeSet

Hello everyone,

I have the latest workshop setup with EWM-SDK-Server-7.0.2 and try to develop a Java Server Side Plugin.
I'm creating a participant on the "Save Change Set Links and Comments (server)" action.
Everything is running fine but for IChangeSetHandles I get some weird behaviour.

I tried different ways to get the item handle but always get the same error.
Examples:
IChangeSetHandle handle = (IChangeSetHandle) changeSet.getItemHandle();
IChangeSetHandle handle = (IChangeSetHandle) IChangeSet.ITEM_TYPE.createItemHandle(changeSet.getItemId(), changeSet.getStateId());

I would expect those to produce a IChangeSetHandle Object, but what I get is:

java.lang.ClassCastException: com.ibm.team.scm.common.internal.impl.ChangeSetHandleImpl incompatible with com.ibm.team.repository.service.vvc.model.IChangeSetHandle

For other Handles I don't have any problems (IWorkItemHandle, IWorkSpaceHandle...)


Am I doing something wrong with retrieving the handle or is maybe something wrong with my setup?

Thanks in advance.

0 votes


Accepted answer

Permanent link

You should consider checking your imports. You likely want 


com.ibm.team.scm.common.IChangeSet
and 

com.ibm.team.scm.common.IChangeSetHandle

Not com.ibm.team.repository.service.vvc.model.IChangeSetHandle

It is good to carefully read the error messages, that is often the first step to a solution. I am aware that sometimes you just don't spot it.

If you set up your development environment with the SDK, you can actually open the classes. Then you can see that information below. If you want to know more about how to get there, let me know. 

/
  @see IAuditable
  @since 0.5
  @NoImplement This interface is not intended to be implemented by clients.
 */
public interface IChangeSet extends IChangeSetHandle, IAuditable {

So you can simply cast to the handle.

Fabian Best selected this answer as the correct answer

0 votes

Comments
I had "com.ibm.team.repository.service.vvc.model.IChangeSetHandle" in the imports.
Replacing that with "com.ibm.team.scm.common.IChangeSetHandle" worked for me.
Thanks a lot!

Your answer

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

Question asked: Oct 15 '21, 4:40 a.m.

Question was seen: 873 times

Last updated: Oct 15 '21, 7:48 a.m.

Confirmation Cancel Confirm