getting java class cast exception.
lakshmi jyothsna (37●1●18)
| asked Feb 01 '17, 6:54 a.m.
edited Feb 01 '17, 7:42 a.m. by Ralph Schoon (63.5k●3●36●46) I want to get the owner ID of the work item. I used the below snippet to get the ID . But i end up with an error java class cast exception,
IContributor contributor = (IContributor) teamRepository.itemManager()
.fetchCompleteItem(handle, IItemManager.DEFAULT, null);
String userID=contributor.getUserId();
Please help me how to get Owner ID from Icontributor handle.
Please any one clarify the difference between Owner and Creator of work item in RTC.
Waiting forward for response...
Thanks in advance,.
|
3 answers
Ralph Schoon (63.5k●3●36●46)
| answered Feb 01 '17, 7:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Carefully follow this post and set up your environment for debugging the API: Understanding and Using the RTC Java Client API. In addiion that code does not help if it is unclear where the exception happens and what the handle is. Comments Hi Ralph,
Thanks for your response. We are using that Icontributor handle only. Getowner gives the contributor handle , that we are unable to resolve. we are getting the exception that : workitem is of type model not of type api.common. Kindly help us how to retrive the owner id of work item from contributor handle.
please help us.
thanks.
|
Ralph Schoon (63.5k●3●36●46)
| answered Feb 01 '17, 9:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Feb 01 '17, 9:55 a.m. There is no work item in your code above. You expect anyone to comment on code you don't show in the question?
Carefully follow this post and set up your environment for debugging the API: Understanding and Using the RTC Java Client API. In addiion that code does not help if it is unclear where the exception happens and what the handle is.
See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ to understand how to get the owner. IContributorHandle owner = workItem.getOwner();
|
The exaception thrown to indicate that your code has attempted to cast an object to a subclass of which it is not an instance. This means that ClassCastException occurs when you try to cast an instance of an Object to a type that it is not. Type Casting only works when the casted object follows an is a relationship to the type you are trying to cast to.
It is good practice to guard any explicit casts with an instanceof check first:
if (myApple instanceof Fruit) {
Fruit myFruit = (Fruit)myApple;
}
When will be ClassCastException is thrown:
|
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.