0

I want to copy an issue with this code:

    MutableIssue copiedIssue= ComponentAccessor.getIssueFactory().cloneIssueWithAllFields(issue);
        copiedIssue.setProjectObject(project);
        try {
            copiedIssue=    
                    ComponentAccessor.getIssueManager().
                    .getIssueObject(ComponentAccessor.getIssueManager()..createIssueObject(user,copiedIssue).getKey()); 
        } catch (CreateException e) {
            throw new RuntimeException(e);
        }

... I get this error Message:

... java.lang.RuntimeException:com.atlassian.jira.workflow.WorkflowException: An unknown exception occured executing Validator com.atlassian.jira.workflow.SkippableValidator@4b24c667: root cause: java.lang.NullPointerException ...

This works very fine until now... I just changed somerwhere else the code with active objects but this has no influence on this part of the code and is also not executed(i deleted everything and rebuild it but nothing helped).

1 Answer 1

2

Looking at the few lines of code above does not give me any clue why you see this error. Making use of Active Object API shall not cause any problem in the Issue Creation APIs.

Hints: You are creating Jira issue without validation of the parameters which would have given you better context of the error log and root cause. Also, it's better approach to first validate and then call create method. Something like below:

// First we need to validate the new issue being created

IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
// We're only going to set the summary and description. The rest are hard-coded to
// simplify this tutorial.
issueInputParameters.setSummary(req.getParameter("summary"));
issueInputParameters.setDescription(req.getParameter("description"));
// We need to set the assignee, reporter, project, and issueType...
// For assignee and reporter, we'll just use the currentUser
issueInputParameters.setAssigneeId(user.getName());
issueInputParameters.setReporterId(user.getName());
// We hard-code the project name to be the project with the TUTORIAL key
Project project = projectService.getProjectByKey(user, "TUTORIAL").getProject();
issueInputParameters.setProjectId(project.getId());
// We also hard-code the issueType to be a "bug" == 1
issueInputParameters.setIssueTypeId("1");
// Perform the validation
IssueService.CreateValidationResult result = issueService.validateCreate(user, issueInputParameters);

if (result.getErrorCollection().hasAnyErrors()) {
    // If the validation fails, render the list of issues with the error
    // To Do: Error handling code
} else {
    // If the validation passes, redirect the user to the main issue list page
    issueService.create(user, result);
    resp.sendRedirect("issuecrud");
}

For detail understand please refer the full code here: https://developer.atlassian.com/jiradev/jira-platform/guides/issues/tutorial-jira-issue-crud-servlet-and-issue-search

Hope this would give you better context and help you solve your problem.

Sign up to request clarification or add additional context in comments.

1 Comment

The Problem was that i got a null pointer exception from the user. with the error handling from you i found the error. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.