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

嗨斯科特我改變了執行活動對象的邏輯,但仍然不成功。請解決這個問題 –