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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

java.lang.NullPointerException: Cannot invoke method setIssue() on null object Edited

Hi,

I had a working script but after upgrade to JIRA 8.5. I have to replace component manager.

I did that but now i get Null pointer exception.

Below is the script. Any help is appreciated.

import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue;

//import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.crowd.embedded.api.User
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.util.SimpleErrorCollection
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.atlassian.jira.config.ResolutionManager

import org.apache.log4j.Logger
import static org.apache.log4j.Level.DEBUG
log.setLevel(org.apache.log4j.Level.DEBUG)

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.workflow.TransitionOptions

import com.atlassian.jira.issue.IssueInputParameters

GroupManager groupManager = ComponentAccessor.getComponent(GroupManager.class)

CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager()
CustomField cf = cfManager.getCustomFieldObject(11907);
Object customFieldValue = (Object) issue.getCustomFieldValue(cf)

Issue parent = issue.getParentObject();
def issueLinkManager = ComponentAccessor.getIssueLinkManager();

def issueManager = ComponentAccessor.getIssueManager();
def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)

IssueService issueService = ComponentAccessor.getIssueService()
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) ComponentAccessor.getComponent(WorkflowTransitionUtilImpl.class);

boolean check = false;

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();

issueLinkManager.getOutwardLinks(issue.getId()).each
{
issueLink ->
MutableIssue linkIssue = issueLink.getDestinationObject() as MutableIssue
if(linkIssue.summary == ('REQ ' + customFieldValue + ' - ' + linkIssue.getParentObject().getSummary()))
{
if(linkIssue.resolution?.name == 'Fixed')
{
check = true;
}else
{
check = false;
}
}
}

issueLinkManager.getOutwardLinks(issue.getId()).each
{
issueLink ->
MutableIssue linkIssue = issueLink.getDestinationObject() as MutableIssue

if((linkIssue.issueType.name == 'Design & Code' || (linkIssue.issueType.name == 'Test Prep.')) && ((linkIssue.summary == 'D&C ' + customFieldValue + ' - ' + linkIssue.getParentObject().getSummary()) || (linkIssue.summary == 'TP ' + customFieldValue + ' - ' + linkIssue.getParentObject().getSummary())) && (linkIssue.status.name == 'Closed') && (linkIssue.resolution?.name == 'Fixed') && check )
{
workflowTransitionUtil.setIssue(linkIssue);    <== ISSUE HERE
workflowTransitionUtil.setUserkey(currentUser);
workflowTransitionUtil.setAction(51);
workflowTransitionUtil.validate();
workflowTransitionUtil.progress();
}
}

1 answer

0 votes
Daniel Ebers Community Leader Nov 08, 2020

Hi Madhavan,

there have been some changes when upgrading to Jira v8. You mentioned the replacement of the ComponentManager - this is indeed a significant one. From my experience simple replacing it won't work.
The Groovy scripts needs a rework in some cases.

Have you checked the documentation on this?
https://scriptrunner.adaptavist.com/5.6.8/jira/releases/UpgradingToJira8.html#_componentmanager_has_been_moved

In case you don't get along with the generic documentation please state where the NPE exactly occurs. The likeliness is then higher that somebody from Community will look into the code and give an advise.

Cheers,
Daniel

Hi Daniel,

Thanks for the support.

I referred the documentation you have referred but still i am unable to make my script working. Looks i'm missing some basics.

In the script which i have in the description(above). I see that linkIssue is null. Eventhough i'm able to get summary and issue type etc from linkIssue.

workflowTransitionUtil.setIssue(linkIssue);    <== ISSUE HERE

Cheers,

Madhavan.J

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you