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

List of Deployment Projects

Jason Schwanz Apr 07, 2015

Java novice here, and I've been sitting at this road block for long enough. I'm trying to write my first add-on, and I want to generate an list of all deployment projects. I've been focusing on DeploymentProjectDaoImpl and ViewAllDeploymentProjects, but no matter how I implement/emulate those I end up with NPE in the end. I expect there is some simple solution I'm missing, and would appreciate any guidance.

Update:

Code and stacktrace.

// attempt 1 code snippet
final ViewAllDeploymentProjects deployProjects = new ViewAllDeploymentProjects(); 
List<DeploymentProject> deploy = deployProjects.getDeploymentProjects();
 
// attempt 1 stacktrace
[INFO] [talledLocalContainer] 2015-04-08 08:20:09,403 ERROR [http-6990-2] [ExceptionMappingInterceptor] null
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at com.atlassian.bamboo.deployments.projects.actions.ViewAllDeploymentProjects.getDeploymentProjects(ViewAllDeploymentProjects.java:30)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateDeployPlan(DeployConfigurator.java:80)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateContextForCreate(DeployConfigurator.java:38)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.TaskUIConfigBean.prepareCreateHtml(TaskUIConfigBean.java:109)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.CreateTask.input(CreateTask.java:55)
...
[INFO] [talledLocalContainer] 2015-04-08 08:20:10,448 ERROR [http-6990-2] [FiveOhOh] 500 Exception was thrown.
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at com.atlassian.bamboo.deployments.projects.actions.ViewAllDeploymentProjects.getDeploymentProjects(ViewAllDeploymentProjects.java:30)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateDeployPlan(DeployConfigurator.java:80)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateContextForCreate(DeployConfigurator.java:38)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.TaskUIConfigBean.prepareCreateHtml(TaskUIConfigBean.java:109)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.CreateTask.input(CreateTask.java:55)
...

// attempt 2 code snippet
final DeploymentProjectDaoImpl deployProjects = new DeploymentProjectDaoImpl();
List<MutableDeploymentProject> deploy = deployProjects.getAllDeploymentProjects();
 
// attempt 2 stacktrace
[INFO] [talledLocalContainer] 2015-04-08 08:31:30,404 ERROR [http-6990-3] [ExceptionMappingInterceptor] null
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at com.atlassian.bamboo.persistence3.HibernateDaoUtils.executeFind(HibernateDaoUtils.java:115)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.deployments.projects.persistence.DeploymentProjectDaoImpl.getAllDeploymentProjects(DeploymentProjectDaoImpl.java:54)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateDeployPlan(DeployConfigurator.java:82)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateContextForCreate(DeployConfigurator.java:40)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.TaskUIConfigBean.prepareCreateHtml(TaskUIConfigBean.java:109)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.CreateTask.input(CreateTask.java:55)
...
[INFO] [talledLocalContainer] 2015-04-08 08:31:30,631 ERROR [http-6990-3] [FiveOhOh] 500 Exception was thrown.
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at com.atlassian.bamboo.persistence3.HibernateDaoUtils.executeFind(HibernateDaoUtils.java:115)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.deployments.projects.persistence.DeploymentProjectDaoImpl.getAllDeploymentProjects(DeploymentProjectDaoImpl.java:54)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateDeployPlan(DeployConfigurator.java:82)
[INFO] [talledLocalContainer] at com.example.bamboo.DeployTask.DeployConfigurator.populateContextForCreate(DeployConfigurator.java:40)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.TaskUIConfigBean.prepareCreateHtml(TaskUIConfigBean.java:109)
[INFO] [talledLocalContainer] at com.atlassian.bamboo.ww2.actions.build.admin.config.task.CreateTask.input(CreateTask.java:55)
...

Update 2:

// class
package com.example.bamboo.DeployTask;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.atlassian.bamboo.deployments.projects.DeploymentProject;
import com.atlassian.bamboo.deployments.projects.service.DeploymentProjectService;
import com.atlassian.bamboo.ww2.BambooActionSupport;

@SuppressWarnings("serial")
public class DeployProjects extends BambooActionSupport {
        @SuppressWarnings("unused")
        private static final Logger log = Logger.getLogger(DeployProjects.class);
        private List<DeploymentProject> deploymentProjects;
        @Autowired
        private DeploymentProjectService deploymentProjectService;
        public List<DeploymentProject> getDeploymentProjects()
        {
                if (deploymentProjects == null)
                {
                        deploymentProjects = deploymentProjectService.getAllDeploymentProjects();
                }
                return deploymentProjects;
        }
}

// call
final DeployProjects deployProjects = new DeployProjects();
List<DeploymentProject> deploy = deployProjects.getDeploymentProjects();
// stacktrace
[INFO] [talledLocalContainer] 2015-04-10 09:03:53,366 ERROR [http-6990-3] [ExceptionMappingInterceptor] null
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]   at com.example.bamboo.DeployTask.DeployProjects.getDeploymentProjects(DeployProjects.java:27)
[INFO] [talledLocalContainer]   at com.example.bamboo.DeployTask.DeployConfigurator.populateDeployPlan(DeployConfigurator.java:82)
[INFO] [talledLocalContainer]   at com.example.bamboo.DeployTask.DeployConfigurator.populateContextForCreate(DeployConfigurator.java:40)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.ww2.actions.build.admin.config.task.TaskUIConfigBean.prepareCreateHtml(TaskUIConfigBean.java:109)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.ww2.actions.build.admin.config.task.CreateTask.input(CreateTask.java:55)
...
[INFO] [talledLocalContainer] 2015-04-10 09:03:53,766 ERROR [http-6990-3] [FiveOhOh] 500 Exception was thrown.
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer]   at com.example.bamboo.DeployTask.DeployProjects.getDeploymentProjects(DeployProjects.java:27)
[INFO] [talledLocalContainer]   at com.example.bamboo.DeployTask.DeployConfigurator.populateDeployPlan(DeployConfigurator.java:82)
[INFO] [talledLocalContainer]   at com.example.bamboo.DeployTask.DeployConfigurator.populateContextForCreate(DeployConfigurator.java:40)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.ww2.actions.build.admin.config.task.TaskUIConfigBean.prepareCreateHtml(TaskUIConfigBean.java:109)
[INFO] [talledLocalContainer]   at com.atlassian.bamboo.ww2.actions.build.admin.config.task.CreateTask.input(CreateTask.java:55)
...

4 answers

0 votes
Silviu Burcea Apr 07, 2015

NPEs are the easiest to fix. Show us the stacktrace and your code.

0 votes
Jason Schwanz Apr 08, 2015

I've updated the question with stacktrace and code snippets for both methods I've attempted.

0 votes
Krystian Brazulewicz Atlassian Team Apr 09, 2015

Jason - download Bamboo source code and look for examples. In your code you should never use DAO directly, use DeploymentProjectService and other Service/Managers

Jason Schwanz Apr 10, 2015

I had previously downloaded the source, and that's where I found com.atlassian.bamboo.deployments.projects.actions.ViewAllDeploymentProjects (via viewAllDeploymentProjects.ftl). I've updated the question with my latest attempt by implementing the DeploymentProjectService from the example of ViewAllDeploymentProjects.

Jason Schwanz Apr 16, 2015

@Krystian Brazulewicz I've gone throughout the source code, and what I'm attempting in Update 2 is what I find. Do you have any guidance for my next steps?

0 votes
Jason Schwanz Apr 16, 2015

@Silviu Burcea I've posted code and stacktrace results of the methods I've tried. From exploring the source code for examples my Update 2 is doing what appears to work in other places, but I still get a NPE.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

5,054 views 21 25
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