1

我是jira主动对象实现中的新手。 我发现实现使用jTrick http://www.j-tricks.com/tutorials/active-objects-injectionJIRA主动对象异常

活动对象时的误差“无法创建新的参考LazyLoadedServletReference {描述符= com.atlassian.jira.demo.aoDemo:地址列表(A servlet来添加和目录地址), s[email protected]3a0a701} [INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference $ InitializationException:java.lang.NullPointerException:插件容器访问器为null。Plugin: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的构造

相关代码

公共AddressServlet的依赖(IAOServ ice aoService){
if(aoService!= null){
this.aoService = aoService; else 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> 

波姆代码

<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年9月14日11:26:37451 HTTP-NIO-2990-EXEC-2 DEBUG管理员686x211x1 1x1imyf 172.17.20.51 /rest/plugins/1.0/com.atlassian。 jira.demo.aoDemo键 [caactiveobjects.osgi.OsgiServiceUtilsImpl]注册服务 [email protected]与 接口net.java.ao.schema.TableNameConverter和属性 {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 /休息/插件/ 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和 属性{com.atlassian.plugin.key = com.atlassian.jira.demo.aoDemo} [INFO] [talledLocalContainer] 2016年9月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 [caactiveobjects.osgi.ActiveObjectsServiceFactory] onPluginModuleEnabledEvent存储用于[com.atlassian.jira.demo.aoDemo] [INFO] [talledLocalContainer] 2016年9月14日11未附接配置 模块:26:37463的HTTP-NIO-2990-EXEC-2 DEBUG管理员686x211x1 1x1imyf 172.17.20.51 /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key [caactiveobjects.osgi.ActiveObjectsServiceFactory] ​​ onPluginEnabledEvent附着未结合到 [com.atlassian.jira.demo.aoDemo] [INFO] [talledLocalContainer ] 2016-09-14 11:26:37,463 http-nio-2990-exec-2 DEBUG管理员686x211x1 1x1imyf 172.17.20.51 /rest/plugins/1.0/com.atlassian.jira.demo.aoDemo-key [ [info.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 [caactiveobjects.osgi.TenantAwareActiveObjects]软件包 [com.atlassian.jira.demo.aoDemo]加载新的AO承诺 JiraTenantImpl {id ='system'} [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 [caactiveobjects.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 [caactiveobjects.osgi.TenantAwareActiveObjects]软件包 [com.atla ssian.jira.demo.aoDemo]获取ActiveObjectsConfiguration [INFO] [talledLocalContainer] 2016-09-14 11:26:37,474 active-objects-init-JiraTenantImpl {id ='system'} - 0 DEBUG admin
[ca activeobjects.osgi.TenantAwareActiveObjects]包 [com.atlassian.jira.demo.aoDemo]创建ActiveObjects [INFO] [talledLocalContainer] 2016-09-14 11:26:37,488 active-objects-init-JiraTenantImpl {id ='系统'} - 0 DEBUG管理员
[caactiveobjects.osgi.TenantAwareActiveObjects]束 [com.atlassian.jira.demo.aoDemo]建立ActiveObjects [INFO] [talledLocalContainer] 2016年9月14日11:26:47872 HTTP -nio-2990-exec-9 错误管理员686x226x1 1x1imyf 172.1 51年7月20日 /插件/ servlet的/ addressservlet [caplugin.servlet.DefaultServletModuleManager]无法创建新 参考 LazyLoadedServletReference {描述符= com.atlassian.jira.demo.aoDemo:地址列表 (A servlet来添加和列表地址), s[email protected]3a0a701} [INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference $ InitializationException: 显示java.lang.NullPointerException:插件容器存取器空值。 插件:com.atlassian.jira.demo.aoDemo。模块名称: com.atlassian.jira.demo.Servlet.AddressServlet。[INFO] [talledLocalContainer]在 com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149) [INFO] [talledLocalContainer]在 com.atlassian.util.concurrent.LazyReference.get(LazyReference。的java:112) [INFO] [talledLocalContainer]在 com.atlassian.plugin.servlet.DefaultServletModuleManager.getInstance(DefaultServletModuleManager.java:374) [INFO] [talledLocalContainer]在 com.atlassian.plugin.servlet.DefaultServletModuleManager。 getServlet(DefaultServletModuleManager.java:353) [INFO] [talledLocalContainer] at com.atlassian.plugin.servlet.DefaultServletModuleManager.getServlet(DefaultServletModuleManager.java:171) [INFO] [talledLocalContainer]在 com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:36) [INFO] [talledLocalContainer]在 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]在 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。 [INFO] [talledLocalContainer]在 com.google.common.base.Preconditions.checkNotNull(Preconditions.java:250) [INFO] [talledLocalContainer]在 com.atlassian.plugin.module.ClassPrefixModuleFactory.createModule(ClassPrefixModuleFactory。的java:32) [INFO] [talledLocalContainer]在 com.atlassian.plugin.module.PrefixDelegatingModuleFactory.createModule(PrefixDelegatingModuleFactory.java:88) [INFO] [talledLocalContainer]在 com.atlassian.plugin.servlet.descriptors。 ServletModuleDescriptor.getModule(ServletModuleDescriptor.java:43) [INFO] [talledLocalContainer] at com.atlassian.plugin.servlet.DelegatingPluginServlet。(DelegatingPluginServlet.java:30) [INF O] [talledLocalContainer]在 com.atlassian.plugin.servlet.DefaultServletModuleManager $ LazyLoadedServletReference.create(DefaultServletModuleManager.java:456) [INFO] [talledLocalContainer]在 com.atlassian.util.concurrent.LazyReference $ Sync.run( LazyReference.java:325) [INFO] [talledLocalContainer]在 com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:143) [INFO] [talledLocalContainer] ... 211更

+0

你能发布一个更完整的代码示例吗? –

+0

雅这是我的代码'私人最终的ActiveObjects ao; \t \t 公共ActiveServiceImpl(){ \t \t this.ao = ComponentAccessor.getOSGiComponentInstanceOfType(ActiveObjects.class); \t \t System.out.println(“---------------------------------------- ---------------------------------“); \t \t System.out.println(“ActiveObject Instance is”+ this.ao); \t} \t \t公共无效addEntity(字符串名称,地址字符串,字符串国家){ \t \t \t} \t' –

+0

1-能否请您编辑您原来的问题添加代码,而不是将它插入到注释中(行结束被剥离)? 2你发布的代码实际上并没有显示对你所说的“activeobject.create()”的调用。 3-发布整个异常(包括堆栈跟踪的完整异常类型和后续行)将会很有帮助。 –

回答

0

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

我相信会发生这种情况,因为GetOSGIComponentInstanceOfType从主JIRA(Pico)容器中返回一个单独的AO上下文,该容器不知道您的插件,而您希望为您的插件自己的实体配置AO。

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

+1

嗨斯科特!解决方案没有奏效将Active Object传递给servlet构造函数servlet未找到(404)异常被抛出。你可以创建一个在jira中使用AO的模板。 –

+0

检查日志 - 如果你得到404,这可能是因为你的插件没有初始化,应该记录在其中。发布MCVE(http://stackoverflow.com/help/mcve)一般也是提问者的责任。 –

+0

嗨斯科特我改变了执行活动对象的逻辑,但仍然不成功。请解决这个问题 –