JIRA活动对象异常

时间:2016-05-31 12:19:57

标签: jira jira-plugin jira-rest-api jira-agile jira-rest-java-api

我是jira活动对象实现的新手。 使用jTrick实现活动对象时发现错误 http://www.j-tricks.com/tutorials/active-objects-injection

"无法创建新引用LazyLoadedServletReference {descriptor = com.atlassian.jira.demo.aoDemo:address-list(要添加和列出地址的servlet),servletContext = org.apache.catalina.core.ApplicationContextFacade @ 3a0a701} [INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference $ InitializationException:java.lang.NullPointerException:插件容器访问器为null。插件:com.atlassian.jira.demo.aoDemo。模块名称:com.atlassian.jira.demo.Servlet.AddressServlet。"

IAOService.java的代码

public interface IAOService {
public ActiveObjects getActiveObjects();}

IAOServiceImpl的代码

public class IAOServiceImpl implements IAOService {
private final ActiveObjects ao;

public IAOServiceImpl(ActiveObjects ao) {
    System.out.println("Initializing constructor impl");
    System.out.println("IAOServiceImpl constructor found active object ::"+ao);
    this.ao=ao;         
}
public ActiveObjects getActiveObjects() {
    return this.ao;
}}

我在servlet构造函数中注入依赖项

依赖代码

  

public AddressServlet(IAOService aoService){
  if(aoService!= null){
      this.aoService = aoService;其他        this.aoService = NULL; }

     

我在我的插件中禁用了atlassian-plugin-scanner功能。

请帮我解决这个问题。

我还在插件描述符文件中提到了ao模块。

插件描述符代码:

<ao key="ao-module">
<description>Configuration of active object service</description>
<entity>sample.AddressEntity</entity>

<component-import key="ao" name="Active Objects service" interface="com.atlassian.activeobjects.external.ActiveObjects">
<description>Component to access Active Objects functionality from the plugin</description></component-import>

Pom代码

<pluginArtifact>
    <groupId>com.atlassian.activeobjects</groupId>
    <artifactId>activeobjects-plugin</artifactId>
    <version>${ao.version}</version>
</pluginArtifact>
<pluginArtifact>
    <groupId>com.atlassian.activeobjects</groupId>
    <artifactId>activeobjects-jira-spi</artifactId>
    <version>${ao.version}</version>
</pluginArtifact>

Ao.version是0.18

异常堆栈

  

[INFO] [talledLocalContainer] 2016-09-14 11:26:37,451   http-nio-2990-exec-2 DEBUG admin 686x211x1 1x1imyf 172.17.20.51   /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key   [c.a.activeobjects.osgi.OsgiServiceUtilsImpl]注册服务   net.java.ao.atlassian.AtlassianTableNameConverter@677b0082 with   interface net.java.ao.schema.TableNameConverter和properties   {com.atlassian.plugin.key = com.atlassian.jira.demo.aoDemo} [INFO]   [talledLocalContainer] 2016-09-14 11:26:37,453 http-nio-2990-exec-2   DEBUG admin 686x211x1 1x1imyf 172.17.20.51   /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key   [c.a.activeobjects.osgi.OsgiServiceUtilsImpl]注册服务   com.atlassian.activeobjects.config.internal.DefaultActiveObjectsConfiguration@7e886a2b   带接口   com.atlassian.activeobjects.config.ActiveObjectsConfiguration和   properties {com.atlassian.plugin.key = com.atlassian.jira.demo.aoDemo}   [INFO] [talledLocalContainer] 2016-09-14 11:26:37,457   http-nio-2990-exec-2 DEBUG admin 686x211x1 1x1imyf 172.17.20.51   /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key   [c.a.activeobjects.osgi.ActiveObjectsServiceFactory]   onPluginModuleEnabledEvent存储未附加的配置   [com.atlassian.jira.demo.aoDemo]的模块[INFO]   [talledLocalContainer] 2016-09-14 11:26:37,463 http-nio-2990-exec-2   DEBUG admin 686x211x1 1x1imyf 172.17.20.51   /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key   [c.a.activeobjects.osgi.ActiveObjectsServiceFactory]   onPluginEnabledEvent附加未绑定到   [com.atlassian.jira.demo.aoDemo] [INFO] [talledLocalContainer]   2016-09-14 11:26:37,463 http-nio-2990-exec-2 DEBUG admin 686x211x1   1x1imyf 172.17.20.51   /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key   [c.a.activeobjects.osgi.TenantAwareActiveObjects] init bundle   [com.atlassian.jira.demo.aoDemo] [INFO] [talledLocalContainer]   2016-09-14 11:26:37,464 http-nio-2990-exec-2 DEBUG admin 686x211x1   1x1imyf 172.17.20.51   /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key   [c.a.activeobjects.osgi.TenantAwareActiveObjects]包   [com.atlassian.jira.demo.aoDemo]加载新的AO承诺   JiraTenantImpl {id =&#39; system&#39;} [INFO] [talledLocalContainer] 2016-09-14   11:26:37,464 http-nio-2990-exec-2 DEBUG admin 686x211x1 1x1imyf   172.17.20.51 /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] setAoConfiguration   [com.atlassian.jira.demo.aoDemo] [INFO] [talledLocalContainer]   2016-09-14 11:26:37,464 http-nio-2990-exec-2 DEBUG admin 686x211x1   1x1imyf 172.17.20.51   /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key   [c.a.activeobjects.osgi.TenantAwareActiveObjects]包   [com.atlassian.jira.demo.aoDemo]获得了ActiveObjectsConfiguration [INFO]   [talledLocalContainer] 2016-09-14 11:26:37,474   active-objects-init-JiraTenantImpl {id =&#39; system&#39;} - 0 DEBUG admin
  [c.a.activeobjects.osgi.TenantAwareActiveObjects]包   [com.atlassian.jira.demo.aoDemo]创建ActiveObjects [INFO]   [talledLocalContainer] 2016-09-14 11:26:37,488   active-objects-init-JiraTenantImpl {id =&#39; system&#39;} - 0 DEBUG admin
  [c.a.activeobjects.osgi.TenantAwareActiveObjects]包   [com.atlassian.jira.demo.aoDemo]创建了ActiveObjects [INFO]   [talledLocalContainer] 2016-09-14 11:26:47,872 http-nio-2990-exec-9   ERROR admin 686x226x1 1x1imyf 172.17.20.51   /插件/的servlet / addressservlet   [c.a.plugin.servlet.DefaultServletModuleManager]无法创建新的   参考   LazyLoadedServletReference {描述符= com.atlassian.jira.demo.aoDemo:地址列表   (要添加和列出地址的servlet),   servletContext=org.apache.catalina.core.ApplicationContextFacade@3a0a701}   [INFO] [talledLocalContainer]   com.atlassian.util.concurrent.LazyReference $ InitializationException:   java.lang.NullPointerException:插件容器访问器为null。   插件:com.atlassian.jira.demo.aoDemo。模块名称:   com.atlassian.jira.demo.Servlet.AddressServlet。 [信息]   [talledLocalContainer]在   com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)   [INFO] [talledLocalContainer] at   com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.servlet.DefaultServletModuleManager.getInstance(DefaultServletModuleManager.java:374)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:353)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:171)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:36)   [INFO] [talledLocalContainer] at   javax.servlet.http.HttpServlet.service(HttpServlet.java:725)[INFO]   [talledLocalContainer] ... 70过滤[INFO] [talledLocalContainer]   在   com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59)   [INFO] [talledLocalContainer] ... 38过滤[INFO]   [talledLocalContainer]在   com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)   [INFO] [talledLocalContainer] ... 91过滤[INFO]   [talledLocalContainer]在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)   [INFO] [talledLocalContainer] at   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617)   [INFO] [talledLocalContainer] at   org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)   [INFO] [talledLocalContainer] at   java.lang.Thread.run(Thread.java:745)[INFO] [talledLocalContainer]   引起:java.lang.NullPointerException:插件容器访问器   一片空白。插件:com.atlassian.jira.demo.aoDemo。模块名称:   com.atlassian.jira.demo.Servlet.AddressServlet。 [信息]   [talledLocalContainer]在   com.google.common.base.Preconditions.checkNotNull(Preconditions.java:250)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.module.ClassPrefixModuleFactory.createModule(ClassPrefixModuleFactory.java:32)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.module.PrefixDelegatingModuleFactory.createModule(PrefixDelegatingModuleFactory.java:88)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.servlet.descriptors.ServletModuleDescriptor.getModule(ServletModuleDescriptor.java:43)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.servlet.DelegatingPluginServlet。(DelegatingPluginServlet.java:30)   [INFO] [talledLocalContainer] at   com.atlassian.plugin.servlet.DefaultServletModuleManager $ LazyLoadedServletReference.create(DefaultServletModuleManager.java:456)   [INFO] [talledLocalContainer] at   com.atlassian.util.concurrent.LazyReference $ Sync.run(LazyReference.java:325)   [INFO] [talledLocalContainer] at   com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:143)   [INFO] [talledLocalContainer] ... 211 more

1 个答案:

答案 0 :(得分:0)

而不是调用ComponentAccessor.getOSGIComponentInstanceOfType,而是应该将ActiveObjects注入到servlet的构造函数中。无论如何,这是推荐的设计模式,at least one source表明不使用注入访问AO会以与上述类似的方式中断。

我相信这是因为GetOSGIComponentInstanceOfType从主JIRA(Pico)容器返回单个AO上下文,该容器不知道您的插件,而您想要为您的插件自己的实体配置AO。

请注意,servlet已经自动连线,因此您无需创建单独的<component>,如上面的链接所示 - 只需将ActiveObjects作为构造函数参数添加到您的servlet中并将其保存在您的servlet中课程供以后使用。