karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Pieber <anpie...@gmail.com>
Subject Re: Spring DM - OSGI service register and use in the same bundle
Date Tue, 01 Feb 2011 08:11:44 GMT
TBH I've never took a look into springs source to know y, but it doesn't like it
if you import in the same bundle you export it. Simple solution is to split into
to different bundles (as jb suggested), or use the bean txManager directly
instead of the service. 

BTW, it doesn't matter if you define you beans in one or 10 .xml files in one
bundle. Spring "concats" them first and start to load them afterwards.

kind regards,
andreas

On Tue, Feb 01, 2011 at 08:58:59AM +0100, Charles Moulliard wrote:
> Hi,
> 
> I try to register an OSGI Service and use it in the same bundle but
> get an unsatisfied dependencies error.
> 
> Is it allow to do that ?
> 
> Error :
> 
> 08:54:40,317 | INFO  | ExtenderThread-2 | DependencyServiceManager
>     | startup.DependencyServiceManager  288 | 76 -
> org.springframework.osgi.extender - 1.2.0 | Adding OSGi service
> dependency for importer
> [&org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean#0]
> matching OSGi filter
> [(&(objectClass=org.springframework.transaction.PlatformTransactionManager)(tx=JPA))]
> 08:54:40,318 | INFO  | ExtenderThread-2 | DependencyServiceManager
>     | startup.DependencyServiceManager  232 | 76 -
> org.springframework.osgi.extender - 1.2.0 |
> OsgiBundleXmlApplicationContext(bundle=com.goodyear.emea.gicl.esb.sap-all,
> config=osgibundle:/META-INF/spring/*.xml) is waiting for unsatisfied
> dependencies [[&org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean#0]]
> 
> Config
> 
>         aaa.xml file
> 
> 	<!-- TransactionManager is required -->
> 	<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
> 		<property name="entityManagerFactory" ref="entityManagerFactory" />
> 		<property name="dataSource" ref="dataSource" />
> 	</bean>
> 	
> 	<!--  Expose Transaction Manager -->
> 	<osgi:service ref="txManager"
> interface="org.springframework.transaction.PlatformTransactionManager">
>             <service-properties>
>                 <entry key="tx" value="JPA"/>
>             </service-properties>
>         </osgi:service>
> 
> 
>     bbb.xml file
> 
> 	<bean id="PROPAGATION_REQUIRES_NEW"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>         <property name="transactionManager">
> 	       <osgi:reference filter="(tx=JPA)"
> interface="org.springframework.transaction.PlatformTransactionManager"/>
>         </property>
>   		<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
> 	</bean>
> 
> Regards,
> 
> Charles Moulliard
> 
> Sr. Principal Solution Architect - FuseSource
> Apache Committer
> 
> Blog : http://cmoulliard.blogspot.com
> Twitter : http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard
> Skype: cmoulliard

Mime
View raw message