404 on custom plugin path when using PermissionAdminService class in java servlet

I am developing a small plugin extension for an internal facing instance of Bitbucket. It will expose admins of projects and repositories to users that are not a part of that project, so that they can contact the admins and get proper access and relieve the global admins of that duty.

I am using a basic servlet class:

package com.atlassian.bitbucket.plugin.servlet;

import com.atlassian.soy.renderer.SoyTemplateRenderer;
import com.atlassian.bitbucket.project.Project;
import com.atlassian.bitbucket.project.ProjectService;
import com.atlassian.bitbucket.permission.Permission;
import com.atlassian.bitbucket.permission.PermissionAdminService;
import com.atlassian.bitbucket.permission.SetPermissionRequest;
import com.atlassian.bitbucket.user.UserService;
import com.atlassian.bitbucket.util.Page;
import com.atlassian.bitbucket.util.PageRequest;
import com.atlassian.bitbucket.util.PageRequestImpl;
import com.google.common.collect.ImmutableMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ProjectServlet extends AbstractExampleServlet {
    private final ProjectService projectService;
    private final PermissionAdminService permissionAdminService;

    public ProjectServlet(SoyTemplateRenderer soyTemplateRenderer, ProjectService projectService, PermissionAdminService permissionAdminService) {
        this.projectService = projectService;
        this.permissionAdminService = permissionAdminService;

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // Get projectKey from path
        String pathInfo = req.getPathInfo();

        String[] components = pathInfo.split("/");

        if (components.length < 2) {

        Project project = projectService.getByKey(components[1]);

        if (project == null) {

        boolean isSettings = false;
        if (components.length == 3 && "settings".equalsIgnoreCase(components[2])) {
            isSettings = true;

        String template = isSettings ? "plugin.example.projectSettings" : "plugin.example.project";

        render(resp, template, ImmutableMap.<String, Object>of("project", project));

When using PermissionAdminService, my plugin path returns a 404 "Could not find servlet for: /plugins/servlet/example/project/". When I remove the PermissionAdminService and just use ProjectService, everything works correctly and I can navigate to my context path fine.

I can leave the import statement intact and remove actual usage of the PermissionAdminService class and the plugin builds without failure, which leads me to believe that the class is included in the dependencies I am downloading via maven (using Atlassian SDK).


Any help on this would be greatly appreciated.

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

309 views 0 12
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you