How to fix NullPointerException due to deprecated getPeer() method?
Hi,
o
or
These work fine and I am able to query relevant information with all of them, with the exception of IWorkItemClient or IWorkItemCommon. If I do:
I have also tried to get around the problem by using IQueryableAttributeFactory, but that also gives a NPE in the following form:
I have also tried a couple of other techniques but all lead to the same end issue, which is that a part of the code calls the (deprecated) IAuditableCommon.getPeer() method, which always returns a null. What is the purpose of that method and is there a way to get around it, especially in the context of getting an instance of IWorkItemClient?
Thanks.
|
Accepted answer
hm.. I would use the classpath to the folder -classpath path/* I would try your app without the maven goo first..
on my sample, I just changed it to use V5 to verify for my answer, so it WILL work if you get the right jars there..
Nicolas Poisson selected this answer as the correct answer
Comments
Nicolas Poisson
commented Jun 19 '14, 8:38 a.m.
I have set the classpath to the entire folder as you suggested instead of picking and choosing the jars to use and it is now working as expected (with maven).
Thanks for your time.
|
2 other answers
see my sample code here,
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes the accepted answer, which will print the attributes of workitems returned from a (pre-defined) query. shows all the services connected, etc.. plain java watch out for the forum changing code inside <> to all lower case. Comments
Nicolas Poisson
commented Jun 18 '14, 3:10 p.m.
Hi,
Thanks for the answer, but it does not fix my current predicament with the getPeer() method always returning nulls.
In your example, the queryClient.findSharedQueries() line eventually calls AuditableCommon.update(AuditableCommon.java:183), which causes a NPE because of the previous line's use of getPeer(IWorkItemCommon.class);
|
how did you define the set of plain java jar files used by your application?
on mine in Eclipse I made a user Library that points to the entire plain java folder. (both windows & linux the same approach). this utility has worked unchanged since 3.0 without unexpected exceptions same on 5.0 just now there are 8 plans available and 8 records Query result initialized: true accurate: true estimated: -1 available: 7 total: 7 1 1 Define a new build processing for variable=Archived attrib type=boolean kind= attribute id=archived, type=boolean value=false processing for variable=Filed Against attrib type=category kind= Category name=test cacdf 5 processing for variable=Restricted Access attrib type=uuid kind=null attribute id=contextId, type=uuid value=[UUID _bkmAEO5NEeO7H9hzQ2Ddug] processing for variable=Corrected Estimate attrib type=duration kind=null attribute id=correctedEstimate, type=duration value=-1 processing for variable=Creation Date attrib type=timestamp kind=null attribute id=creationDate, type=timestamp value=2014-06-07 09:10:29.868 altho u say 'plain java', it sounds like you are trying to do this server side, cause you shouldn't need to use getpeer() on the client. (see my code that loads IWorkItemCommon.class). you can do the same thing on the server side. add IWorkItemCommon.class as a plugin requiredService then use the AbstractService.getService(IWorkItemCommon.class). (your plugin should extend AbstractService) for example IWorkItemServer workItemService = getService(IWorkItemServer.class); Comments
Nicolas Poisson
commented Jun 18 '14, 4:26 p.m.
I'm building with Maven, which gets its RTC plugin jars from our Nexus server.
Then for execution, I have a batch file that has a reaaaally long classpath with all the needed jars in it (just the ones I need though). This is meant to be executed as a client, I do not have the server stuff installed on my machine. And I also do not use getPeer() explicitly, it's just that for every attempt I make to get the client (including exactly as you have done it) eventually the getPeer() method gets called from within the RTC code and I have no way of bypassing it.
|
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.