It's all about the answers!

Ask a question

Jazz client API java.lang.NullPointerException


Mostafa Radwan (1158) | asked Jul 31 '13, 9:56 a.m.
edited Jul 31 '13, 10:28 a.m.
Hi Everyone,

I'm using the plain Java client code (link below) to be able to create a work item pragmatically.
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

It works successfully but I'm getting the following  java.lang.NullPointerException in the output and it's related to the following line of code :

ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);

I'm using RTC v3.0.1.1 and download the corresponding RTC Client API JARs . Here are my questions :-

(1) Any idea what might be causing this ?
(2) I'm planning to be able to create,edit, and close work items problematically. Is this the Jazz client API enough
or shall I investigate on a REST API alternative ?

Thanks,


Output:
======

java.lang.NullPointerException
    at com.ibm.team.repository.common.internal.util.VersionStringComparator.getIntegerParts(VersionStringComparator.java:71)
    at com.ibm.team.repository.common.internal.util.VersionStringComparator.innerCompare(VersionStringComparator.java:45)
    at com.ibm.team.repository.common.internal.util.VersionStringComparator.compare(VersionStringComparator.java:32)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor$EvolutionDescriptorComponentVersionComparator.compare(ModelElementDescriptor.java:152)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor$EvolutionDescriptorComponentVersionComparator.compare(ModelElementDescriptor.java:1)
    at java.util.TreeMap.compare(Unknown Source)
    at java.util.TreeMap.put(Unknown Source)
    at java.util.TreeSet.add(Unknown Source)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor.processEvolutionElement(ModelElementDescriptor.java:60)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor.processChild(ModelElementDescriptor.java:53)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.processChildren(AbstractElementDescriptor.java:725)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.<init>(AbstractElementDescriptor.java:60)
    at com.ibm.team.repository.common.internal.util.AbstractComponentChildElementDescriptor.<init>(AbstractComponentChildElementDescriptor.java:30)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor.<init>(ModelElementDescriptor.java:37)
    at com.ibm.team.repository.common.internal.util.ComponentElementDescriptor.processChild(ComponentElementDescriptor.java:262)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.processChildren(AbstractElementDescriptor.java:725)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.<init>(AbstractElementDescriptor.java:60)
    at com.ibm.team.repository.common.internal.util.ComponentElementDescriptor.<init>(ComponentElementDescriptor.java:39)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.handleExtensionAdded(ComponentRegistry.java:860)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.handleExtensionAdded(ComponentRegistry.java:1)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.basicHandleExtensionAdded(ExtensionRegistryReader.java:205)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.handleExtensionAddedToRegistry(ExtensionRegistryReader.java:624)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.addContributedExtensions(ExtensionRegistryReader.java:143)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.start(ExtensionRegistryReader.java:1129)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.earlyStart(ExtensionRegistryReader.java:318)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.<init>(ExtensionRegistryReader.java:114)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.<init>(ComponentRegistry.java:75)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.<clinit>(ComponentRegistry.java:47)
    at com.ibm.team.repository.common.LogFactory.getLog(LogFactory.java:71)
    at com.ibm.team.repository.client.internal.TeamRepositoryService.<clinit>(TeamRepositoryService.java:70)
    at com.ibm.team.repository.client.TeamPlatform.getTeamRepositoryService(TeamPlatform.java:126)
    at com.ibm.team.workitem.ide.ui.example.CreateWorkItem.run(CreateWorkItem.java:131)
    at com.ibm.team.workitem.ide.ui.example.CreateWorkItem.main(CreateWorkItem.java:101)
Jul 31, 2013 8:42:52 AM com.ibm.team.repository.common.transport.AbstractElementDescriptor processChildren
SEVERE: null
java.lang.NullPointerException
    at com.ibm.team.repository.common.internal.util.VersionStringComparator.getIntegerParts(VersionStringComparator.java:71)
    at com.ibm.team.repository.common.internal.util.VersionStringComparator.innerCompare(VersionStringComparator.java:45)
    at com.ibm.team.repository.common.internal.util.VersionStringComparator.compare(VersionStringComparator.java:32)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor$EvolutionDescriptorComponentVersionComparator.compare(ModelElementDescriptor.java:152)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor$EvolutionDescriptorComponentVersionComparator.compare(ModelElementDescriptor.java:1)
    at java.util.TreeMap.compare(Unknown Source)
    at java.util.TreeMap.put(Unknown Source)
    at java.util.TreeSet.add(Unknown Source)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor.processEvolutionElement(ModelElementDescriptor.java:60)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor.processChild(ModelElementDescriptor.java:53)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.processChildren(AbstractElementDescriptor.java:725)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.<init>(AbstractElementDescriptor.java:60)
    at com.ibm.team.repository.common.internal.util.AbstractComponentChildElementDescriptor.<init>(AbstractComponentChildElementDescriptor.java:30)
    at com.ibm.team.repository.common.internal.util.ModelElementDescriptor.<init>(ModelElementDescriptor.java:37)
    at com.ibm.team.repository.common.internal.util.ComponentElementDescriptor.processChild(ComponentElementDescriptor.java:262)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.processChildren(AbstractElementDescriptor.java:725)
    at com.ibm.team.repository.common.transport.AbstractElementDescriptor.<init>(AbstractElementDescriptor.java:60)
    at com.ibm.team.repository.common.internal.util.ComponentElementDescriptor.<init>(ComponentElementDescriptor.java:39)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.handleExtensionAdded(ComponentRegistry.java:860)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.handleExtensionAdded(ComponentRegistry.java:1)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.basicHandleExtensionAdded(ExtensionRegistryReader.java:205)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.handleExtensionAddedToRegistry(ExtensionRegistryReader.java:624)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.addContributedExtensions(ExtensionRegistryReader.java:143)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.start(ExtensionRegistryReader.java:1129)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.earlyStart(ExtensionRegistryReader.java:318)
    at com.ibm.team.repository.common.util.ExtensionRegistryReader.<init>(ExtensionRegistryReader.java:114)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.<init>(ComponentRegistry.java:75)
    at com.ibm.team.repository.common.internal.util.ComponentRegistry.<clinit>(ComponentRegistry.java:47)
    at com.ibm.team.repository.common.LogFactory.getLog(LogFactory.java:71)
    at com.ibm.team.repository.client.internal.TeamRepositoryService.<clinit>(TeamRepositoryService.java:70)
    at com.ibm.team.repository.client.TeamPlatform.getTeamRepositoryService(TeamPlatform.java:126)
    at com.ibm.team.workitem.ide.ui.example.CreateWorkItem.run(CreateWorkItem.java:131)
    at com.ibm.team.workitem.ide.ui.example.CreateWorkItem.main(CreateWorkItem.java:101)

Created work item 200809.


 

2 answers



permanent link
Ralph Schoon (58.0k23642) | answered Jul 31 '13, 10:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You should consider reading http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ and you should probably debug your code or split your failing expression to find out what part is null.

My experience with null pointer exceptions:

Null Pointer and Other Exceptions

I get exceptions, the API is broken!

My experience so far is, that it was usually my fault. I didn’t understand the API, failed to resolve another item or made wrong assumptions that led to exceptions. The best approach is to really look into all parameters you pass. Also check if the client libraries you intent to get using the getClientLibraries() really return. One example where you won’t get it that way is the is the IContributorManager, which you don’t get using this call, but using ITeamRepository.getContributorManager(). If you try to get the Client Library otherwise it will return null.


You either use the REST API or the Java API. Today, I think the Java API allows to do more than the REST API and I find it easier to handle and debug. This is obviously a personal preference though.

Comments
Mostafa Radwan commented Jul 31 '13, 11:46 a.m.

Thanks Ralph, I'll troubleshoot the issue.


permanent link
sam detweiler (12.4k6180201) | answered Jul 31 '13, 10:40 a.m.
did you copy the code exactly?

this line should be called before the one that failed

TeamPlatform.startup();

I use the same approach in many of my java clients and it works fine. 


Comments
Mostafa Radwan commented Jul 31 '13, 11:46 a.m.


Sam,
 I actually have the call to TeamPlatform.startup() in a static closure at the very beginning as in the code. I copied it as it is.

Do I have to install the RTC client on the machine ? I'm just using a plain java object and the RTC Jars.

Regards,


Ralph Schoon commented Jul 31 '13, 11:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

No, you don't need to install the client. All the required classes should be in the Plain Java Client Library Jar's.


Mostafa Radwan commented Jul 31 '13, 11:51 a.m.

Thanks Ralph for your prompt response.....I'll continue troubleshooting and let you know how it goes.

One final question, Using the Java Client API I should be able to create,edit, and close work items in RTC pragmatically .. correct ?  Pardon my typo earlier :)


Ralph Schoon commented Jul 31 '13, 11:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Hi Mostafa,

who am I to blame others for typos? 8-)

Yes you can create, update, edit, change state on work Items. I try to provide a lot of information around that on my blog. I'd suggest to start there: http://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ and search for what you are interested in.


Mostafa Radwan commented Jul 31 '13, 12:14 p.m.

Many Thanks :)

Your answer


Register or to post your answer.