It's all about the answers!

Ask a question

Uploading an attachment using Plain Java API does not work with Jazz version 7.0.2


Ana-Maria Rosu (261) | asked May 26, 8:48 a.m.
edited Jul 14, 4:29 a.m.

Hello everyone,


I am trying to upload an attachment to a work item in Jazz via Plain Java API.

For Jazz version 7.0 this works just fine. Recently the server was upgraded to version 7.0.2 and the same code that worked before now is throwing an error (see below). I've tested also the code for downloading the attachments and it seems to be working for both versions.

Do you have any information about this issue?

Thank you,
Ana


Error message:
[Test worker] ERROR com.ibm.team.process.common - CRJAZ2675I A client action caused the server exception that is listed below. The identifier for the error is 4f5c183a-9b72-407c-86a5-56c8c51d7f54.
java.lang.IllegalArgumentException: Item id and State id must not be null
CRJAZ2796E Details about the error were written to the server log file. To find this data, search the log file for this identifier: E56CBD90FF0545D32B01B3AD554CF84CA523212C.
at com.ibm.team.repository.common.internal.marshal.util.MarshallerUtil.decodeExceptions(MarshallerUtil.java:377)
at com.ibm.team.repository.common.internal.marshal.util.MarshallerUtil.decodeExceptions(MarshallerUtil.java:347)
at com.ibm.team.repository.common.internal.marshal.util.MarshallerUtil.decodeFault(MarshallerUtil.java:312)
at com.ibm.team.repository.transport.client.RemoteTeamService.constructExceptionFromFault(RemoteTeamService.java:716)
at com.ibm.team.repository.transport.client.RemoteTeamService.executeMethod(RemoteTeamService.java:559)
at com.ibm.team.repository.transport.client.RemoteTeamService.invoke(RemoteTeamService.java:202)
at com.ibm.team.repository.transport.client.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:43)
at com.sun.proxy.$Proxy68.save(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invokeServiceCall(ServiceInterfaceProxy.java:254)
at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:110)
at com.sun.proxy.$Proxy68.save(Unknown Source)
at com.ibm.team.workitem.client.internal.WorkItemSaveTransport$1.run(WorkItemSaveTransport.java:33)
at com.ibm.team.repository.client.internal.TeamRepository$3.run(TeamRepository.java:1355)
at com.ibm.team.repository.common.transport.CancelableCaller.call(CancelableCaller.java:79)
at com.ibm.team.repository.client.internal.TeamRepository.callCancelableService(TeamRepository.java:1350)
at com.ibm.team.workitem.client.internal.WorkItemSaveTransport.call(WorkItemSaveTransport.java:30)
at com.ibm.team.workitem.client.internal.WorkItemSaveRunnable.run(WorkItemSaveRunnable.java:37)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.runRunnable(OperationAdviceManager.java:1504)
at com.ibm.team.process.internal.common.advice.runtime.OperationAdviceManager.execute(OperationAdviceManager.java:209)
at com.ibm.team.process.internal.client.ProcessClientService.execute(ProcessClientService.java:774)
at com.ibm.team.workitem.client.internal.WorkItemClient.save(WorkItemClient.java:577)
at com.ibm.team.workitem.client.internal.WorkItemClient.save(WorkItemClient.java:565)
at com.ibm.team.workitem.common.internal.WorkItemCommon.internalSaveAuditables(WorkItemCommon.java:1348)
at com.ibm.team.workitem.common.internal.WorkItemCommon.internalSaveAuditables(WorkItemCommon.java:1333)
at com.ibm.team.workitem.common.internal.WorkItemCommon.saveAuditables(WorkItemCommon.java:1325)
at com.ibm.team.workitem.common.internal.WorkItemCommon.saveAuditable(WorkItemCommon.java:1315)
at com.ibm.team.workitem.common.internal.WorkItemCommon.saveAttachment(WorkItemCommon.java:1058)
at com.ibm.team.workitem.client.internal.WorkItemClient.createAttachment(WorkItemClient.java:534)

3 answers



permanent link
Davyd Norris (1.1k8) | answered Jun 04, 1:08 a.m.
I had this exact same bug a few weeks ago.

I bet you have an earlier version of the Plain Java Client libraries - make sure you are using the 7.0.2 release and the issue will go away

It's a problem with n-1 compatibility between 7.0.1 clients and 7.0.2 servers - in my case it caused errors while using the Eclipse import wizard when importing Bugzilla items that had attachments

permanent link
Ralph Schoon (59.4k23642) | answered May 26, 10:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited May 26, 10:53 a.m.
I used the old code that went up into the blog you refer to with Java 8, the Plain Java Client Libraries for 7.0.2, and it works without a problem.

Code base on that went into WCL. You could try that as well.https://github.com/jazz-community/work-item-command-line

I used this code with the ModifyWorkItemUploadAttachmentOperation:
        WorkItemUploadAttachmentModification operation = new WorkItemUploadAttachmentModification(
                "TestAttachment.txt", IContent.CONTENT_TYPE_TEXT,
                IContent.ENCODING_UTF_8);
        operation.run(workItem, null);

        WorkItemUploadAttachmentModification operation1 = new WorkItemUploadAttachmentModification(
                "Test.pdf", IContent.CONTENT_TYPE_UNKNOWN,
                IContent.ENCODING_UTF_8);
        operation1.run(workItem, null);



Comments
Ana-Maria Rosu commented May 27, 2:52 a.m.

Hello Ralph,


Thanks for your quick response.

If it works for you, then most probably I'm missing an dependency. I will investigate more.
For the Java Client Libraries do you use the jars in the libs folder or the dependencies in build.gradle? Because if you use the dependencies, it might be easier for me to see which one is missing.

Thanks,
Ana


Ralph Schoon commented May 27, 3:11 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I use dependencies to the Plain Java Client Libraries. I download these from Jazz.net and add them to the classpath. I do not use Gradle and in my case, the code was run from within an Eclipse client.


I doubt you have an issue with dependencies however. You get an java.lang.IllegalArgumentException: Item id and State id must not be null .

Maybe somehow the information about the work item gets lost? I do not know, sorry. I would suggest to test against a test system if you have one, against a different project area etc. I am not sure how to approach this and where the issue may be. I can only say, that my code works for me.


permanent link
David Lafreniere (4.6k7) | answered Jun 03, 3:01 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

The client-side exception as posted doesn't have enough information to tell what went wrong on the server. It does say: "Details about the error were written to the server log file. To find this data, search the log file for this identifier: E56CBD90FF0545D32B01B3AD554CF84CA523212C.".
Go to the server log and paste the server exception here, then I'm sure we can help out further.

Your answer


Register or to post your answer.