Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,296,726
Community Members
 
Community Events
165
Community Groups

Null pointer execption error while fetching plan using PlanManager.

Hi,

Can someone please provide a hint as to what could be going wrong, I am using atlassian-sdk to develop a plugin which displays a new tab when a job containing a specific task (RobotTask) is clicked..

I am getting Null pointer exception error for a very simple thing that I am doing which is fetching the Plan by using the planKey and PlanManager.

Code

64: Plan plan = planManager.getPlanByKey(planKey).

I have a valid plan key which is "TPRO1-TPLAN1-JOB1". Even when I try to use "TPRO1-TPLAN1" as the plan key, I still get the exception...

 

My code looks like this

public boolean shouldDisplay(Map<String, Object> context) {
    	PlanKey planKey = PlanKeys.getPlanKey((String) context.get("planKey"));
        Plan plan = planManager.getPlanByKey(planKey);
       
        List<TaskDefinition> tasks = plan.getBuildDefinition().getTaskDefinitions();
        for(TaskDefinition task : tasks) {
            if(task.getPluginKey().equals(RobotTask.KEY) ) {
                return true;
            }
        }

        return false;
    }

 

Below is the stack strace

[INFO] [talledLocalContainer] 2018-05-10 12:14:39,083 ERROR [http-nio-6990-exec-12] [DefaultWebInterfaceManager] Could not evaluate condition 'isode.robot.RobotReportViewCondition@72267783' for descriptor: isode.robotplugin:KeyWebItemRobotReportTab (null)
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]     at isode.robot.RobotReportViewCondition.shouldDisplay(RobotReportViewCondition.java:64)
[INFO] [talledLocalContainer]     at com.atlassian.plugin.web.DefaultWebInterfaceManager.filterFragmentsByCondition(DefaultWebInterfaceManager.java:153)
[INFO] [talledLocalContainer]     at com.atlassian.plugin.web.DefaultWebInterfaceManager.getDisplayableItems(DefaultWebInterfaceManager.java:106)
[INFO] [talledLocalContainer]     at com.atlassian.bamboo.ww2.BambooActionSupport.getWebItemsForSection(BambooActionSupport.java:431)
[INFO] [talledLocalContainer]     at sun.reflect.GeneratedMethodAccessor1656.invoke(Unknown Source)
[INFO] [talledLocalContainer]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] [talledLocalContainer]     at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer]     at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1459)
[INFO] [talledLocalContainer]     at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:69)
[INFO] [talledLocalContainer]     at freemarker.core.MethodCall._eval(MethodCall.java:76)
[INFO] [talledLocalContainer]     at freemarker.core.Expression.eval(Expression.java:81)
[INFO] [talledLocalContainer]     at freemarker.core.Assignment.accept(Assignment.java:134)
[INFO] [talledLocalContainer]     at freemarker.core.Environment.visit(Environment.java:362)
[INFO] [talledLocalContainer]     at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:239)
[INFO] [talledLocalContainer]     at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:200)
[INFO] [talledLocalContainer]     at freemarker.core.Environment.visitIteratorBlock(Environment.java:595)
[INFO] [talledLocalContainer]     at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:81)
[INFO] [talledLocalContainer]     at freemarker.core.IteratorBlock.accept(IteratorBlock.java:67)
[INFO] [talledLocalContainer]     at freemarker.core.Environment.visit(Environment.java:362)
[INFO] [talledLocalContainer]     at freemarker.core.Environment.invoke(Environment.java:714)
[INFO] [talledLocalContainer]     at freemarker.core.UnifiedCall.accept(UnifiedCall.java:86)
[INFO] [talledLocalContainer]     at freemarker.core.Environment.visit(Environment.java:326)
[INFO] [talledLocalContainer]     at freemarker.core.Environment.visit(Environment.java:368)
[INFO] [talledLocalContainer]     at freemarker.core.Environment.invoke(Environment.java:714)
[

1 comment

I found what the problem was, I did not have the constructor to do the initialization.

Below solved it.

public RobotReportViewCondition(final PlanManager planManager){
this.planManager = planManager;

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Bamboo

Bamboo Data Center on Kubernetes

Hi, If you are running self-managed environments and looking to adopt modern infrastructure, Bamboo Data Center can now be deployed in a Kubernetes cluster. By leveraging Kubernetes, you can easily...

951 views 3 8
Read article

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