Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » "bundleContext property is required"?(Exception trying to get simple (non-web) bundle working under Virgo 3.6)
"bundleContext property is required"? [message #999105] Fri, 11 January 2013 10:59 Go to next message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
I'm migrating a project from Virgo 3.0.5 to 3.6.0 and I'm encountering a strange exception when I deploy a previously-working OSGi bundle to the new server:

java.lang.IllegalArgumentException: bundleContext property is required
	at org.springframework.util.Assert.notNull(Assert.java:112)
	at org.springframework.osgi.compendium.cm.ConfigAdminPropertiesFactoryBean.afterPropertiesSet(ConfigAdminPropertiesFactoryBean.java:59)


The bundle exposes a javax.sql.Datasource as an OSGi service using Spring. When I search online for clues, most references to bundle context relate to WARs. What does this error really mean for my non-web bundle? I'm unclear on exactly how the bundle's context is created anyway.

I had to add org.springframework.osgi.*-1.2.1 bundles to my /usr repo to get the project to build in Eclipse. Could this be related to my problem? These files were included in Eclipse 3.0.x but are missing 3.5-3.6 distributions?

Thanks in advance for any help - this has been driving me nuts for a couple of days!

Full stack trace:

[2013-01-11 10:23:22.419] region-dm-10                 <AG0000E> Application context creation failure for bundle 'com.foo.datasource' version '1.0.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0': Cannot resolve reference to bean 'configProperties' while setting bean property 'properties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configProperties': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: bundleContext property is required
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:401)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.invokeBeanFactoryPostProcessors(AbstractDelegatedExecutionApplicationContext.java:362)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:254)
	at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:220)
	at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:224)
	at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:177)
	at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:157)
	at org.eclipse.gemini.blueprint.extender.internal.activator.LifecycleManager$1.run(LifecycleManager.java:211)
	at org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:680)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configProperties': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: bundleContext property is required
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
	... 22 common frames omitted
Caused by: java.lang.IllegalArgumentException: bundleContext property is required
	at org.springframework.util.Assert.notNull(Assert.java:112)
	at org.springframework.osgi.compendium.cm.ConfigAdminPropertiesFactoryBean.afterPropertiesSet(ConfigAdminPropertiesFactoryBean.java:59)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
	... 29 common frames omitted


MANIFEST.MF

Manifest-Version: 1.0
Bundle-Vendor: Foo
Bundle-Classpath: .
Bundle-Version: 1.0.0
Tool: Bundlor 1.1.0.BUILD-20101220120024
Bundle-Name: Foo Datasource
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.foo.datasource
Import-Package: 
 javax.sql,
 org.apache.commons.logging,
 org.slf4j;version="1.6.4"
Import-Bundle: 
 com.springsource.com.mchange.v2.c3p0;version="[0.9.1.2,0.9.1.2]",
 org.springframework.osgi.core;version="[1.2.1,1.2.1]"


src/META-INF/spring/bundle-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:osgi="http://www.springframework.org/schema/osgi"	
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:osgi-compendium="http://www.springframework.org/schema/osgi-compendium"
	xsi:schemaLocation="http://www.springframework.org/schema/osgi 
						http://www.springframework.org/schema/osgi/spring-osgi.xsd
						http://www.springframework.org/schema/beans 
						http://www.springframework.org/schema/beans/spring-beans.xsd
						http://www.springframework.org/schema/context
						http://www.springframework.org/schema/context/spring-context.xsd
						http://www.springframework.org/schema/osgi-compendium
        				http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd"
						 >

	<!-- ========================= RESOURCE DEFINITIONS ========================= -->
	
	<!--  Create a connection pool data source (using C3P0 lib) for the DB --> 
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" 
	 		p:driverClass="${db.driverClass}" 
	 		p:jdbcUrl="${db.url}"
	 		p:user="${db.username}" 
	 		p:password="${db.password}"
	 		p:idleConnectionTestPeriod="10800"
         	p:maxIdleTime="21600"
         	p:initialPoolSize="3"
        	p:minPoolSize="3"
        	p:maxPoolSize="20"
        	p:debugUnreturnedConnectionStackTraces="true"
	 		destroy-method="close"/>
	 
	 <context:property-placeholder properties-ref="configProperties"/>
	 
	 <osgi-compendium:cm-properties id="configProperties" persistent-id="my_config"/>
	
	 <!-- ========================= OSGi SERVICES ========================= -->
	 
	 <osgi:service ref="dataSource" interface="javax.sql.DataSource"/>
	 
</beans>
Re: "bundleContext property is required"? [message #999115 is a reply to message #999105] Fri, 11 January 2013 11:22 Go to previous messageGo to next message
Chris Frost is currently offline Chris Frost
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Hi,

Is there a particular reason why you need to use the Spring DM bundles? This project migrated to Gemini Blueprint which now ships with Virgo instead of Spring DM. We have had both running at the same time before with no problems but it isn't ideal. I can see both present in your stack trace so this is the first suspect. Moving up to Blueprint should be as simple as changing the bundle and package names in your application.

Chris.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: "bundleContext property is required"? [message #999247 is a reply to message #999115] Fri, 11 January 2013 16:27 Go to previous messageGo to next message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
Chris Frost wrote on Fri, 11 January 2013 06:22
Hi,

Is there a particular reason why you need to use the Spring DM bundles? This project migrated to Gemini Blueprint which now ships with Virgo instead of Spring DM. We have had both running at the same time before with no problems but it isn't ideal. I can see both present in your stack trace so this is the first suspect. Moving up to Blueprint should be as simple as changing the bundle and package names in your application.

Chris.


Hi Chris, many thanks for your reply. I was unaware of the migration to Gemini Blueprint but, after updating my projects, they are working fine. This also answers my question about the missing org.springframework.osgi bundles!

Thanks again for your help.
Re: "bundleContext property is required"? [message #1000204 is a reply to message #999247] Mon, 14 January 2013 08:56 Go to previous message
Chris Frost is currently offline Chris Frost
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Glad I could help.

------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Previous Topic:war to wab
Next Topic:Virgo automatically stops
Goto Forum:
  


Current Time: Thu Oct 23 00:02:48 GMT 2014

Powered by FUDForum. Page generated in 0.02185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software