Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

NullPointerException when trying to link Jira 4.2 issues

Anandhi A July 11, 2012

Here is my code for IssueLinking...

ComponentManager com = ComponentManager.getInstance();

IssueLinkManager issueLinkManager = com.getIssueLinkManager(); //returns null pointer exception

JiraAuthenticationContext authenticationContext = com.getJiraAuthenticationContext();

issueLinkManager.createIssueLink(Long.parseLong(parentissue.getId()),Long.parseLong(childissue.getId()),10010L,1L,authenticationContext.getUser());

I get a NullPointerException while calling getIssueLinkManager()....

Please tell me how to solve this and link 2 existing issues...

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2012

Are you sure the null pointer is thrown there? That line looks okay to me! You can may be add some debug statements to be sure.

Anandhi A July 11, 2012

The exception is thrown in that line only...

I donot know how to proceed.Can u tell me how to perform IssueLinking and what are the necessary jar files for it.

Thank you in advance.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

"Import classes from atlassian-jira4.2.jar" sounds wrong to me

Again, can you tell us where you are doing this? (Answer the question you've been asked, please)

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

The problem for us here is that your code looks fine, so the answer to "how to perform issue linking" is "do what you're already doing"

I've used much the same code in version 4 and version 5 code and it's working for me. That implies your ComponentManager isn't coming in correctly, but there's no way to debug that from here. Where are you doing this? Plugin? Somewhere else? What else can you extract from the ComponentManager? Anything at all?

Anandhi A July 11, 2012

I think the problem is with the ComponentManager. Whatever i try to call from that Instance throws NullPointerException. Im using atlassian-jira4.2.jar file to import all these classes (ComponentManager,IssueLink etc). Im stuck. Can you please tell me which is the right jar to import all classes required for IssueLinking...?? Thank you in advance.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2012

Actually, atlassian-jira4.2 jar is fine. That is where it should come from. But I don't see why the error comes there.

Can you provide us the full stacktrace?

Anandhi A July 11, 2012

I downloaded it from the Maven Repository...Is there any alternate jar file to use for IssueLinking???

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2012

Using SOAP API? !

You can't access ComponentManager in SOAP API. Linking is not possible via SOAP.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

We need a lot more than that, you already told us you're getting an error.

For the third time, tell us where you are doing this? Plugin?

Anandhi A July 11, 2012

Exception in thread "main" <u>java.lang.NullPointerException</u>

at com.atlassian.jira.ComponentManager.getComponentInstanceOfType(ComponentManager.java:451)

at com.mmi.firebirdodartsync.IssueDuplicate.main(IssueDuplicate.java:53)

Anandhi A July 11, 2012

Im doing this in eclipse, using SOAP API and the Jira version is 4.2.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

Arg. How to NOT answer a direct question.

SOAP implies that you're writing an external program, rather than a plugin, but that still might not be the case. One last time, before I get really angry. Where are you doing this? Plugin? External program that uses SOAP? SOAP calls extending Jira?

Give us an overview of the structure too please, and a rough idea of what you're trying to do (on a human level - e.g. "as a user of the text editor called Flibble, I want to see Jira issues expanded to URLs as I type them in"

Anandhi A July 11, 2012

Jobin Kuruvilla

Thank you so much. Is there any way to perform IssueLinking in Jira 4.2 using anyother API using Java??

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2012

What are you trying to do (same what Nic asked) :)

Is it remote or within JIRA itself?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

Yes, via the Jira API, internally. Write a plugin or amend the core code.

Maybe if you could tell us what you are trying to do, we could give you options and pointers.

Anandhi A July 11, 2012

Im trying to write a java code to access Jira from Remote using SOAP API and link 2 existing issues. I have created a SOAPSession and retrieved the RemoteIssues from Jira. But cannot link those 2 issues.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

So you want an external program to link two issues in the same Jira? Is that the right description of your goal?

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2012

Unfortunately, linking is not supported via remote APIs. You can write your own SOAP methods for it and then use them.

See https://developer.atlassian.com/display/JIRADEV/RPC+Endpoint+Plugin+Module

Anandhi A July 11, 2012

Nic.. tats what am trying to do.

Jobin..Thank you so much.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

Ok.

You can't do this via SOAP, you will need to extend SOAP to expose the functions you need, as Jobin has said.

I can't help but point out that if you'd answered the questions asked of you when they were asked, you wouldn't have wasted a load of time getting here.

Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2012
As Jobin says you cannot link issues using the standard RPC interface of jira. If you want to remotely link issues you must use the REST api. Please check http://docs.atlassian.com/jira/REST/latest/#id207536
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2012

Just to add on, that is not available in JIRA 4.2 though. Once you are on JIRA5, you can use the method Dieter pointed to you.

Anandhi A July 12, 2012

Thank you all for your support....

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2012

I think it's the wrong call. For Jira 4.x, I have

IssueLinkManager issueLinkManager = ComponentManager.getInstance().getIssueLinkManager()

TAGS
AUG Leaders

Atlassian Community Events