ActiveObjects: java.lang.reflect.InvocationTargetException


I got an active object reference by using:

ao = ComponentAccessor.getOSGiComponentInstanceOfType(ActiveObjects.class);

but when I try to ise it:

ao.find(<Some class>);

a java.lang.reflect.InvocationTargetException is thrown.

Any idea?



1 answer

1 accepted

1 vote
Answer accepted

ActiveObjects can only be initialized using constructor injection.

The problem is that the object receiving the injected ActiveObject is a spring bean, so all its initialization parameters must be declared in the spring context (META-INF/spring/context.xml) and I am unable to configure ActiveObjects with Spring. Any suggestion?

Hi Jobin, I've also read this interesting article from you:

But I still face the same problem: If I use the JTricksManagerImpl to get a valid reference to the ActiveObject instance, that should also be declared in the spring context:

public class X{

 private ActiveObject ao;

 public X(JTricksManager trick){

	ao = trick.getActiveObjects();



In the spring context...

<beans:bean id="foo" class="X">
    <beans:constructor-arg index="1" ref="trick" />	

And the trick reference should also be included in the context:

<beans:bean id="trick" class="com.jtricks.manager.JTricksManagerImpl">
   <beans:constructor-arg index="1" ref="ActiveObject?????" />	



I've guess I did not get the point from your article:

if (this.jTricksManager == null)
this.jTricksManager = ComponentAccessor.getOSGiComponentInstanceOfType(JTricksManager.class);

It looks like I do not need to inject the JtricksManager object.

I'll try your solution!



it always returns NULL.

Ok. Thank you! mainly because this great article:

Finally, it worked for me.

if (this.jTricksManager == null)
this.jTricksManager = ComponentAccessor.getOSGiComponentInstanceOfType(JTricksManager.class);

it was returning always null becuase it must be called after the spring context is fully initialized, so the problem was in calling it from inside a bean constructor.

Now, I let the bean fully initialize and get the active object reference just before it is going to be used.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


213 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you