ActiveObjects: java.lang.reflect.InvocationTargetException

Hi,

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?

Thanks,

Pablo.

1 answer

1 accepted

1 vote
Accepted answer

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:

http://www.j-tricks.com/1/post/2012/07/active-objects-injection.html

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" />	
</beans:bean>

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?????" />	
</beans:bean>

Pablo.

[Edited]

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!

FYI,

ComponentAccessor.getOSGiComponentInstanceOfType(JTricksManager.class);

it always returns NULL.

Ok. Thank you! mainly because this great article:

http://www.j-tricks.com/1/post/2012/07/active-objects-injection.html

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.

Thanks,

Pablo

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,426 views 0 8
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