JIRA Plugin: User 'admin' exists but has no unique key mapping

来源:互联网 发布:软件配置管理工具 编辑:程序博客网 时间:2024/05/01 21:09

插件启动时报:

[INFO] [talledLocalContainer] Exception in thread "ThreadPoolAsyncTaskExecutor::Thread 11" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myPluginComponent' defined in URL [bundle://156.0:0/META-INF/spring/atlassian-plugins-components.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: User 'admin' exists but has no unique key mapping.

我的 atlassian-plugin.xml 代码:

    <!-- publish our component -->    <component key="myPluginComponent" class="com.cpinec.integration.client.SuperClient" public="true">        <interface>com.cpinec.integration.client.ISuper</interface>    </component>
SuperClient.java:

 public class SuperClient implements ISuper, InitializingBean{    IssueService issueService = ComponentAccessor.getIssueService();    IssueWorkflowManager issueWFMngr = ComponentAccessor.getComponentOfType(IssueWorkflowManager.class);    static List<JiraProject> projects = null;    Map<String, Project> projectMap = new HashMap<String, Project>();    static ApplicationUser admin = null;    @Override    public void afterPropertiesSet() throws Exception{        projects = Parser.parseXML();JiraAuthenticationContext jAC = ComponentAccessor.getJiraAuthenticationContext();jAC.setLoggedInUser(ComponentAccessor.getUserManager().getUserByName("admin"));admin = jAC.getUser();    }

网上的 Editing Issues Fails With the Message - User xxxx exists but has no unique key mapping 说 getUserByName 出了问题,但是我不知道怎么改,又搜了下,EAP Feedback - JIRA 6.0 里最下面的 Chris Fuller 说 “It is a safety check that has identified that your system is broken, but it has no idea why.” 我就在想会不会是因为我的 getUserByName 是在 init method 里面调用的,这个时候插件的状态还不稳定,所以没办法获取 admin 这个账号的信息,然后报错。

试着修改了下:

public class SuperClient implements ISuper, InitializingBean{    IssueService issueService = ComponentAccessor.getIssueService();    IssueWorkflowManager issueWFMngr = ComponentAccessor.getComponentOfType(IssueWorkflowManager.class);    static List<JiraProject> projects = null;    Map<String, Project> projectMap = new HashMap<String, Project>();    private static ApplicationUser admin = null;    @Override    public void afterPropertiesSet() throws Exception{        projects = Parser.parseXML();    }    public static ApplicationUser getAdminUser() {        if (admin == null) {            // Authenticate actions            JiraAuthenticationContext jAC = ComponentAccessor.getJiraAuthenticationContext();            jAC.setLoggedInUser(ComponentAccessor.getUserManager().getUserByName("admin"));            admin = jAC.getUser();        }        return admin;    }
然后只有在需要 admin 账号的地方才调用 getAdminUser 方法,重新跑 atlas-run,通过!!!


0 0
原创粉丝点击