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) ...
Community moderators have prevented the ability to post new answers.
@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.
Jason - download Bamboo source code and look for examples. In your code you should never use DAO directly, use DeploymentProjectService and other Service/Managers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've updated the question with stacktrace and code snippets for both methods I've attempted.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
NPEs are the easiest to fix. Show us the stacktrace and your code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.