Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Access to active objects in a create or comment handler

Stefan Stefan November 7, 2011

Hello,

I wrote my own create or comment handler extends AbstractMessageHandler. I need there some stored values form the active objects. I did the configuration in the atlassian-plugin.xml and I have access with other classes to the data (listener, action etc). But if I put the ActiveObjects in the constructor of the message handler I got a null pointer exception. How can I get the access to the active objects in a message handler?

Best regards

Stefan

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Samuel Le Berrigaud
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 7, 2011

Correct me if I'm wrong, but your mail handler is not developpped as a plugin but rather as an extra class that goes into JIRA's main class path. Is that correct?

If that is the case you won't be able to use your Active Objects service that you created in your plugin. Each Active Objects service is only available within the plugin that defines it.

Stefan Stefan November 7, 2011

I think you are right. I use a plugin with other functions and there is also the mail handler inside. But there is no definition in the atlassian-plugin.xml for the mail handler. For the mail handler I did the registration in the popservice.xml.

Means no chance to get an access to my active objects?

Wojciech Seliga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2011

there is no mail handler plugin point in currently available JIRA versions. JIRA 5.0 is going to have such plugin point at last.

0 votes
Wojciech Seliga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2011

Handler objects are instantiated by JIRA (actually by com.atlassian.jira.service.services.file.AbstractMessageHandlingService) by com.atlassian.jira.service.util.handler.HandlerFactory using parameterless constructors (so injection won't work here).

I think you should be able to access ActiveObjects in your parameterless constructor using ComponentManager.getOSGiComponentInstanceOfType()

I've raised https://jira.atlassian.com/browse/JRA-26188 to track the change to JIRA core to allow DI in the constructor of the handler.

Stefan Stefan November 7, 2011

Ok, with this solution I get the access to ActiveObjects. But when I try to access to "my" objects (ao.find(...)) I get an exception:

2011-11-08 11:39:26,515 QuartzWorker-0 ERROR ServiceRunner Support Create Issue [atlassian.activeobjects.osgi.ActiveObjectsServiceFactory] Could not find any active objects configurations for bundle org.apache.felix.framework.
Did you define an 'ao' module descriptor in your plugin?
Try adding this in your atlassian-plugin.xml file: <ao key='some-key' />
2011-11-08 11:39:26,515 QuartzWorker-0 ERROR ServiceRunner Support Create Issue [service.services.mail.MailFetcherService] Support Create Issue[10010]: Exception: com.atlassian.activeobjects.osgi.NoServicesFoundException: Was expecting at least one service reference for interface <com.atlassian.activeobjects.config.ActiveObjectsConfiguration> and filter <(com.atlassian.plugin.key=org.apache.felix.framework)>. Got null !
com.atlassian.plugin.PluginException: com.atlassian.activeobjects.osgi.NoServicesFoundException: Was expecting at least one service reference for interface <com.atlassian.activeobjects.config.ActiveObjectsConfiguration> and filter <(com.atlassian.plugin.key=org.apache.felix.framework)>. Got null !

I think when I access with ComponentManager to the AO there is no "link" to my atlassian-plugin.xml ao description? What I did wrong?

Wojciech Seliga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2011

Have you tried using AO via your own component specified normaly in atlassian-plugin.xml. You would call a method on this compoment from a handler via ComponentManager.getOSGiComponentInstanceOfType(YourComponent). That could trick AO to work.

Stefan Stefan November 7, 2011

This is it! Many thanks for the support!!!

sgupta0102 May 22, 2014

Hi Wojciech Seliga

I am facing same problem.

as per your suggestion i tried like

ActiveObjects ao = ComponentAccessor.getOSGiComponentInstanceOfType(ActiveObjects.class);

TestPlanCaseExecution tp = ao.create(TestPlanCaseExecution.class);

but its not working ......

any suggestion

TAGS
AUG Leaders

Atlassian Community Events