It's all about the answers!

Ask a question

Get IChangeSetHandle from IChangeSet


Fabian Best (131) | asked Oct 15 '21, 4:40 a.m.
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.

Accepted answer


permanent link
Ralph Schoon (60.9k33643) | answered Oct 15 '21, 7:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 15 '21, 7:42 a.m.

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

Comments
Fabian Best commented Oct 15 '21, 7:48 a.m.
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 to post your answer.