Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Timing on deploying a Plan
Timing on deploying a Plan [message #926403] Fri, 28 September 2012 12:19 Go to next message
Justin Stewart is currently offline Justin Stewart
Messages: 6
Registered: September 2012
Junior Member
Hi, all -

I have a simple plan file that deploys 7 subsystem bundles, each of which exposes and references services.

<?xml version="1.0" encoding="UTF-8"?>
<plan name="my.plan" version="1.0.0" scoped="false" atomic="true">
    <artifact type="bundle" name="interfaces.internal" version="0"/>
    <artifact type="bundle" name="subsystems.data" version="0"/>
    <artifact type="bundle" name="subsystems.settings" version="0"/>
    <artifact type="bundle" name="subsystems.aaa" version="0"/>
    <artifact type="bundle" name="subsystems.devices" version="0"/>
    <artifact type="bundle" name="subsystems.restful" version="0"/>
    <artifact type="bundle" name="subsystems.mitigation" version="0"/>
    <artifact type="bundle" name="subsystems.web" version="0"/>
</plan>


Unfortunately, it is not working - the errors seem to indicate a race condition, since they are not determinate (they change with each run). But they're all similar to this:

[2012-09-28 09:49:23.970] region-dm-9                  <AG0000E> Application context creation failure for bundle 'subsystems.aaa' version '1.0.0.SNAPSHOT'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aaaSubsystemImpl' defined in URL [file:/opt/virgo-tomcat-server/work/org.eclipse.virgo.kernel.deployer_3.5.0.RELEASE/staging/global/bundle/subsystems.aaa/1.0.0.SNAPSHOT/aaa-1.0.0.SNAPSHOT.jar/subsystems/aaa/AaaSubsystemImpl.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [subsystems.aaa.AaaSubsystemImpl]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'subsystems.aaa.AaaSubsystemImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private interfaces.internal.subsystems.aaa.GroupsDataSource subsystems.aaa.AaaSubsystemImpl.groupsDataSource; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [interfaces.internal.subsystems.aaa.GroupsDataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)


Sometimes the error refers to a different bundle, but it's the same scenario - a service one bundle has published to Virgo cannot be autowired to another bundle that is referencing it. (Note that I don't have any cyclic service usage.)

However, if instead of using the plan file, I copy each bundle (in the same order) to the Virgo pickup directory with a five second delay between each bundle deploy, I see no errors and the application works just fine.

With the plan file, it's almost like the services of each bundle don't have time to be registered and initialized before they are referenced - and thus the autowiring problem.
Is there something I'm missing or is this a known issue?

Thanks.
Justin
Re: Timing on deploying a Plan [message #931555 is a reply to message #926403] Wed, 03 October 2012 06:07 Go to previous messageGo to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-Schwartz
Messages: 448
Registered: July 2009
Senior Member
Hi Justin.

Are you using SpringDM to register and obtain your services? SpringDM typically takes care of these timing issues nicely for you, waiting to activate any bundle until the services it requires are available. (At least, it does for me!... Wink

B.
Re: Timing on deploying a Plan [message #932981 is a reply to message #931555] Thu, 04 October 2012 12:24 Go to previous messageGo to next message
Justin Stewart is currently offline Justin Stewart
Messages: 6
Registered: September 2012
Junior Member
Hi, Barbara - thanks for the response.
Are referring to the use of osgi:service and osgi:reference elements in the spring configuration files?
If so, then yes, I have been using them - before and after this problem started occurring.
If not, could you enlighten me on the mechanism you are referring to?

Thanks.
Justin
Re: Timing on deploying a Plan [message #937752 is a reply to message #932981] Tue, 09 October 2012 04:24 Go to previous messageGo to next message
Barbara Rosi-Schwartz is currently offline Barbara Rosi-Schwartz
Messages: 448
Registered: July 2009
Senior Member
Hi Justin.

Sorry for the delay in my reply. I am referring exactly to the tags you mention, so we are using the same mechanism. No bright ideas as to why you experience the problems you mention, so sorry.

B.
Re: Timing on deploying a Plan [message #938223 is a reply to message #937752] Tue, 09 October 2012 13:20 Go to previous message
Justin Stewart is currently offline Justin Stewart
Messages: 6
Registered: September 2012
Junior Member
Hi, Barbara -

Thanks for the response. I just discovered the issue - one or both of the following tags in the Spring context file were causing the problem.

	<context:load-time-weaver/>
	<context:spring-configured />


I suspect it was the load-time-weaver causing Spring to try to resolve the service dependencies immediately rather than waiting for them to initialize before wiring.

Anyway, glad that got resolved!
Thanks.
Justin
Previous Topic:Maven repository for Virgo artifacts?
Next Topic:Application wide configuration
Goto Forum:
  


Current Time: Fri Apr 18 11:42:22 EDT 2014

Powered by FUDForum. Page generated in 0.01878 seconds