How do I create a WorkItem in Java using RTC Plain Java 4.0.2?
IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class); IWorkItemWorkingCopyManager copyManager = workItemClient.getWorkItemWorkingCopyManager(); IWorkItemHandle handle = workItemClient.findWorkItemById(1000, IWorkItem.FULL_PROFILE, null); try { copyManager.connect(handle, IWorkItem.FULL_PROFILE, null); WorkItemWorkingCopy itemCopy = copyManager.getWorkingCopy(handle); IWorkItem item = itemCopy.getWorkItem(); System.out.println("Found work item: " + item.getHTMLSummary()); }finally {
}
Accepted answer
Comments
https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ might also be of interest, if you want to set work item attributes.
That was perfect. I used the code in my own class with a few variable amendments to set the ISeverity, Works great:)
Ibrahim, please be aware, if you want to update an existing work item, you have to provide the desired load profile and pass it in the constructor. I think you can find an example for that in https://rsjazz.wordpress.com/2012/08/01/uploading-attachments-to-work-items/
One other answer
When I create a simple java application, there's no problem but when I create a dynamic web project for web service creation, I got error below when my code reaches to TeamPlatform.startup(); line.
I am using axis2.
Does anyone have a clue about this problem?
I added all SDK files to WEB-INF/lib folder.
[ERROR] org/eclipse/core/runtime/CoreException
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:144)
at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:139)
at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:837)
at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:273)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException
at com.ibm.team.repository.client.TeamPlatform.startup(TeamPlatform.java:49)
at CreateWorkItem.run(CreateWorkItem.java:41)
... 34 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 36 more
Comments
You're sure all libs are in the WEB-INF/lib folder? It's throwing a different error but it can't find the CoreException class to show you what the other error is. Maybe the libs were added later and you need to restart the container?
org.eclipse.core.filesystem_1.3.1.R36x_v20100727-0745.jar
org.eclipse.core.jobs_3.5.2.R36x_v20110419.jar
org.eclipse.core.resources_3.6.2.R36x_v20110628-1020.jar
org.eclipse.core.resources_3.6.2.R36x_v20120712-1700.jar
org.eclipse.core.runtime_3.6.0.v20100505.jar
org.eclipse.emf.common_2.6.0.v20100914-1218.jar
org.eclipse.emf.ecore_2.6.1.v20100914-1218.jar
org.eclipse.emf.ecore.change_2.5.1.v20100907-1643.jar
org.eclipse.emf.ecore.xmi_2.5.0.v20100521-1846.jar
org.eclipse.equinox.common_3.6.0.v20100503.jar
org.eclipse.equinox.preferences_3.3.1.R36x_v20110302.jar
org.eclipse.equinox.registry_3.5.0.v20100503.jar
they're all in the WEB-INF/lib directory. I cleaned tomcat and redeployed. I also re-created the project. Still the same issue.