RTC plun-in, api
hi
my name is seyoung
I'm stuyding RTC java-api (server side)
When i make task, automatically i'd like to make parent(story id :21)
this is my source
IWorkItemServer wiServer = getService(com.ibm.team.workitem.service.IWorkItemServer.class);
int workItemNumber=21;
IWorkItem story_workItem = wiServer.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, null); IReference reference = IReferenceFactory.INSTANCE.createReferenceToItem(story_workItem);
WorkItemWorkingCopy workingCopy = (WorkItemWorkingCopy) workItem.getWorkingCopy();
workingCopy.getReferences().add(WorkItemEndPoints.PARENT_WORK_ITEM, reference);
Problem
An error occurred during "Save Work Item".
java.lang.NoClassDefFoundError: com.ibm.team.workitem.client.WorkItemWorkingCopy
An error occurred during "Save Work Item".
java.lang.NoClassDefFoundError: com.ibm.team.workitem.client.WorkItemWorkingCopy
although i add api( com.ibm.team.workitem.client.WorkItemWorkingCopy;)
,but i can't use related to WorkItemWorkingCopy..
1. can i use client-api in server-side???
2. there is another solution??? for workingcopy...
2 answers
Hi, you need to use the WorkingCopyManager, see the code below. As described in http://rsjazz.wordpress.com/2012/08/01/uploading-attachments-to-work-items/ I personally prefer to use the WorkItemOperation as described in https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation which nicely wraps all the fiddly bits and leaves doing the part I am really interested in. I try to collect examples I found in the blog. Only issue: Wordpress is blocked in China.
IWorkItemClient workItemService = (IWorkItemClient) targetRepository
.getClientLibrary(IWorkItemClient.class);
IWorkItemHandle handle = workItemService.getWorkItemWorkingCopyManager()
.connectNew(mappedInternalWorkItemType, monitor);
WorkItemWorkingCopy wc = workItemService.getWorkItemWorkingCopyManager()
.getWorkingCopy(handle);
IWorkItem workItem = wc.getWorkItem();
try {
workItem.setCreator(workPackageInitialCreator);
workItem.setOwner(workPackageInitialOwner);
workItem.setHTMLSummary(XMLString
.createFromPlainText(sSummary));
workItem.setHTMLDescription(XMLString
.createFromPlainText(sDescript));
try {
if (!workItem.hasCustomAttribute(externalIDWorkItemAttribute)) {
IAttribute newAttribute = externalIDWorkItemAttribute;
workItem.addCustomAttribute(newAttribute);
workItem.setValue(newAttribute, sFId);
}
} catch (RuntimeException e) {
System.out.println(e.getMessage());
System.out.println(e.toString());
e.printStackTrace();
}
IDetailedStatus s = wc.save(monitor);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item",
s.getException());
}
} finally {
workItemService.getWorkItemWorkingCopyManager().disconnect(workItem);
}
IWorkItemClient workItemService = (IWorkItemClient) targetRepository
.getClientLibrary(IWorkItemClient.class);
IWorkItemHandle handle = workItemService.getWorkItemWorkingCopyManager()
.connectNew(mappedInternalWorkItemType, monitor);
WorkItemWorkingCopy wc = workItemService.getWorkItemWorkingCopyManager()
.getWorkingCopy(handle);
IWorkItem workItem = wc.getWorkItem();
try {
workItem.setCreator(workPackageInitialCreator);
workItem.setOwner(workPackageInitialOwner);
workItem.setHTMLSummary(XMLString
.createFromPlainText(sSummary));
workItem.setHTMLDescription(XMLString
.createFromPlainText(sDescript));
try {
if (!workItem.hasCustomAttribute(externalIDWorkItemAttribute)) {
IAttribute newAttribute = externalIDWorkItemAttribute;
workItem.addCustomAttribute(newAttribute);
workItem.setValue(newAttribute, sFId);
}
} catch (RuntimeException e) {
System.out.println(e.getMessage());
System.out.println(e.toString());
e.printStackTrace();
}
IDetailedStatus s = wc.save(monitor);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item",
s.getException());
}
} finally {
workItemService.getWorkItemWorkingCopyManager().disconnect(workItem);
}
Hi Ralph,
I am trying to create a workitem using java client. While executing below line:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "Defect", monitor);
i am getting following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jface/text/BadLocationException
at com.ibm.team.process.internal.client.ThinClientProcess.createConfigurationData(ThinClientProcess.java:329)
at com.ibm.team.process.internal.client.ThinClientProcess.getProjectConfigurationData(ThinClientProcess.java:280)
at com.ibm.team.workitem.client.internal.AuditableClientProcess.findProcessConfiguration(AuditableClientProcess.java:72)
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.resolveProcessConfiguration(ConfigurationItemManager.java:124)
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.readConfigurationItems(ConfigurationItemManager.java:107)
at com.ibm.team.workitem.common.internal.WorkItemTypeManager.readConfigurationItems(WorkItemTypeManager.java:370)
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.updateCache(ConfigurationItemManager.java:99)
at com.ibm.team.workitem.common.internal.util.CacheHelper.internalCheckCache(CacheHelper.java:107)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:73)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:65)
DEBUG [main] (InternalTeamPlatform.java:212) - Thread[main,5,main]
DEBUG [main] (InternalTeamPlatform.java:212) - shutdown stopped: false
DEBUG [main] (InternalTeamPlatform.java:212) - setting stopped variables
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.findConfigurationItems(ConfigurationItemManager.java:48)
at com.ibm.team.workitem.common.internal.WorkItemCommon.findWorkItemTypes(WorkItemCommon.java:435)
at com.bosch.RTC.Example.WorkItemCreation.createWorkItem(WorkItemCreation.java:49)
at com.bosch.RTC.Example.WorkItemCreation.main(WorkItemCreation.java:36)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jface.text.BadLocationException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 14 more
Any solution to this?
Thanks,
Sud
I am trying to create a workitem using java client. While executing below line:
IWorkItemType workItemType = service.findWorkItemType(projectArea, "Defect", monitor);
i am getting following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jface/text/BadLocationException
at com.ibm.team.process.internal.client.ThinClientProcess.createConfigurationData(ThinClientProcess.java:329)
at com.ibm.team.process.internal.client.ThinClientProcess.getProjectConfigurationData(ThinClientProcess.java:280)
at com.ibm.team.workitem.client.internal.AuditableClientProcess.findProcessConfiguration(AuditableClientProcess.java:72)
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.resolveProcessConfiguration(ConfigurationItemManager.java:124)
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.readConfigurationItems(ConfigurationItemManager.java:107)
at com.ibm.team.workitem.common.internal.WorkItemTypeManager.readConfigurationItems(WorkItemTypeManager.java:370)
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.updateCache(ConfigurationItemManager.java:99)
at com.ibm.team.workitem.common.internal.util.CacheHelper.internalCheckCache(CacheHelper.java:107)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:73)
at com.ibm.team.workitem.common.internal.util.CacheHelper.checkCache(CacheHelper.java:65)
DEBUG [main] (InternalTeamPlatform.java:212) - Thread[main,5,main]
DEBUG [main] (InternalTeamPlatform.java:212) - shutdown stopped: false
DEBUG [main] (InternalTeamPlatform.java:212) - setting stopped variables
at com.ibm.team.workitem.common.internal.ConfigurationItemManager.findConfigurationItems(ConfigurationItemManager.java:48)
at com.ibm.team.workitem.common.internal.WorkItemCommon.findWorkItemTypes(WorkItemCommon.java:435)
at com.bosch.RTC.Example.WorkItemCreation.createWorkItem(WorkItemCreation.java:49)
at com.bosch.RTC.Example.WorkItemCreation.main(WorkItemCreation.java:36)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jface.text.BadLocationException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 14 more
Any solution to this?
Thanks,
Sud