1

I am newbie in jira active object implementation. I found the error when implementing active object using jTrick http://www.j-tricks.com/tutorials/active-objects-injection

"Unable to create new reference LazyLoadedServletReference{descriptor=com.atlassian.jira.demo.aoDemo:address-list (A servlet to add and list Address), servletContext=org.apache.catalina.core.ApplicationContextFacade@3a0a701} [INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.NullPointerException: Plugin container accessor is null. Plugin: com.atlassian.jira.demo.aoDemo. Module name: com.atlassian.jira.demo.Servlet.AddressServlet."

Code for IAOService.java

public interface IAOService {
public ActiveObjects getActiveObjects();}

Code for 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;
}}

I Inject the dependency in servlet constructor

Dependency code

public AddressServlet(IAOService aoService){
if(aoService!=null) {
this.aoService=aoService; else this.aoService=null; }

I disable the atlassian-plugin-scanner functionality in my plugin.

Please help me out to solve this issue.

I also mention ao module in plugin descriptor file.

Plugin Descriptor code :

<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 code

<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 is 0.18

Exception stack

[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] Registering service net.java.ao.atlassian.AtlassianTableNameConverter@677b0082 with interface net.java.ao.schema.TableNameConverter and 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] Registering service com.atlassian.activeobjects.config.internal.DefaultActiveObjectsConfiguration@7e886a2b with interface com.atlassian.activeobjects.config.ActiveObjectsConfiguration and 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 storing unattached configuration module for [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 attaching unbound to [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] bundle [com.atlassian.jira.demo.aoDemo] loading new AO promise for 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 [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] bundle [com.atlassian.jira.demo.aoDemo] got ActiveObjectsConfiguration [INFO] [talledLocalContainer] 2016-09-14 11:26:37,474 active-objects-init-JiraTenantImpl{id='system'}-0 DEBUG admin
[c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.atlassian.jira.demo.aoDemo] creating ActiveObjects [INFO] [talledLocalContainer] 2016-09-14 11:26:37,488 active-objects-init-JiraTenantImpl{id='system'}-0 DEBUG admin
[c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.atlassian.jira.demo.aoDemo] created ActiveObjects [INFO] [talledLocalContainer] 2016-09-14 11:26:47,872 http-nio-2990-exec-9 ERROR admin 686x226x1 1x1imyf 172.17.20.51 /plugins/servlet/addressservlet [c.a.plugin.servlet.DefaultServletModuleManager] Unable to create new reference LazyLoadedServletReference{descriptor=com.atlassian.jira.demo.aoDemo:address-list (A servlet to add and list Address), servletContext=org.apache.catalina.core.ApplicationContextFacade@3a0a701} [INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.NullPointerException: Plugin container accessor is null. Plugin: com.atlassian.jira.demo.aoDemo. Module name: com.atlassian.jira.demo.Servlet.AddressServlet. [INFO] [talledLocalContainer] at 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 filtered [INFO] [talledLocalContainer] at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59) [INFO] [talledLocalContainer] ... 38 filtered [INFO] [talledLocalContainer] at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70) [INFO] [talledLocalContainer] ... 91 filtered [INFO] [talledLocalContainer] at 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] Caused by: java.lang.NullPointerException: Plugin container accessor is null. Plugin: com.atlassian.jira.demo.aoDemo. Module name: com.atlassian.jira.demo.Servlet.AddressServlet. [INFO] [talledLocalContainer] at 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

Lalit Hira
  • 31
  • 6
  • Can you post a more complete example of your code? – Scott Dudley Jun 01 '16 at 16:39
  • Ya this is my code `private final ActiveObjects ao; public ActiveServiceImpl(){ this.ao=ComponentAccessor.getOSGiComponentInstanceOfType(ActiveObjects.class); System.out.println("-------------------------------------------------------------------------"); System.out.println("ActiveObject Instance is "+ this.ao); } public void addEntity(String name,String address,String country) { } ` – Lalit Hira Jun 02 '16 at 06:18
  • 1- Can you please edit your original question to add the code, rather than inserting it in a comment (where line ends get stripped)? 2- The code you posted doesn't actually show the call to "activeobject.create()" you said was not working. 3- Posting the entire exception (including the full exception type and subsequent lines of the stack trace) would be helpful. – Scott Dudley Jun 02 '16 at 14:04
  • Hi Scott it will be helpful if you can provide me a working sample – Lalit Hira Jun 03 '16 at 13:28

1 Answers1

0

Instead of calling ComponentAccessor.getOSGIComponentInstanceOfType, you should instead inject ActiveObjects into the constructor of your servlet. This is the recommended design pattern anyway, and at least one source suggests that accessing AO without using injection will break in a manner similar to what you have described above.

I believe this occurs because the GetOSGIComponentInstanceOfType is returning a single AO context from the main JIRA (Pico) container which does not know about your plugin, whereas you want the AO that is configured for your plugin's own entities.

Note that servlets are already auto-wired, so you do not need to bother creating a separate <component> like shown in the link above--just add ActiveObjects as a constructor argument to your servlet and save it within your class for later use.

Scott Dudley
  • 3,256
  • 1
  • 18
  • 30
  • 1
    Hi Scott ! Solution not worked. Passing Active Object into servlet constructor servlet not found (404) exception is thrown. Can u create a template for using the AO in jira. – Lalit Hira Jun 08 '16 at 12:32
  • Check the logs--if you're getting a 404, it's probably because your plugin didn't initialize for a reason that should be documented therein. It is also generally the question-asker's responsibility to post a MCVE (http://stackoverflow.com/help/mcve). – Scott Dudley Jun 08 '16 at 12:52
  • Hi Scott i change the logic of implementing active object but still not succeed . Please solve this issue – Lalit Hira Sep 14 '16 at 06:16