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

How do I create a WorkItem in Java using RTC Plain Java 4.0.2?

I am trying to create a WorkItem using RTC Java API v4.0.2(as my RTC Server is of the same version)

So far I can query an item using an ID, but how do I go about creating a Workitem and set its properties such as Priority and Title, then save it?

My code so far to query by an ID is as below, but I want to amend this so it creates an Incident with some properties set.

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 {
}

1

0 votes


Accepted answer

Permanent link
Please carefully read https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation. I usually use the method described at the top using extending the WorkItemOperation. It works for me since 2.x, I think. You might also find https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ interesting, if you want to work with the client API.
Ibrahim Saheb selected this answer as the correct answer

2 votes

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

Permanent link
I want to create a web service to create a workitem.

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

0 votes

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.

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: Jan 09 '14, 12:43 p.m.

Question was seen: 3,551 times

Last updated: Jan 24 '14, 3:43 a.m.

Confirmation Cancel Confirm