aries-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Holly Cummins <holly.k.cumm...@googlemail.com>
Subject Re: Blueprint service dependencies
Date Fri, 20 Apr 2012 15:16:35 GMT
In the blog sample we handle this by putting the datasource bundle in  
config.ini and then using fileinstall to load the rest of the  
application from the load directory, so that it gets loaded second.

However, I have a feeling that we fixed things in trunk a while ago so  
that we didn't have a start order dependency for datasources? Does  
anyone remember for sure?

Holly
---
Enterprise OSGi in Action: http:///manning.com/cummins


On 20 Apr 2012, at 11:09, Pau Minoves <pau.minoves@i2cat.net> wrote:

> Hi,
>
> I'm having the same problem here. In my case it is intermitent and  
> happens mostly (maybe only) with pax exam. Sometimes integration  
> tests fail because of this, if we keep insisting they eventually pass.
>
> In my case, the inner most exception is:
>
> Caused by: javax.naming.NameNotFoundException: osgi:service/ 
> javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/opennaas- 
> resources)"
> 		at org.apache.aries.jndi.url.ServiceRegistryContext.lookup 
> (ServiceRegistryContext.java:110)
> 		at org.apache.aries.jndi.url.ServiceRegistryContext.lookup 
> (ServiceRegistryContext.java:141)
> 		at org.apache.aries.jndi.DelegateContext.lookup 
> (DelegateContext.java:161)
> 		at javax.naming.InitialContext.lookup(InitialContext.java:392)
> 		at  
> org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getDs( 
> DelayedLookupDataSource.java:55)
> 		... 43 more
>
> In my case, the dataSource blueprint definition and persistence.xml  
> are in the same file, but I've no idea if this may impact. Any tips  
> welcome, thanks!
>
> Best regards,
> Pau
>
>
> On Thu, Apr 19, 2012 at 5:34 PM, Brunner Basil  
> <basil@entwinemedia.com> wrote:
> Hi
>
> I have two OSGi bundles The first one contains only a Blueprint data  
> source definition:
>
> ====================
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>
>  <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
>    <property name="URL" value="jdbc:h2:db/database" />
>  </bean>
>
>  <service interface="javax.sql.DataSource" ref="dataSource">
>    <service-properties>
>      <entry key="osgi.jndi.service.name" value="jdbc/database" />
>    </service-properties>
>  </service>
>
> </blueprint>
> ====================
>
> The second bundle contains a JPA persistence file and a blueprint  
> file:
>
> ====================
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
>
>  <persistence-unit name="CaptureAgentCore" transaction-type="JTA">
>    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ 
> provider>
>    <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name 
> =jdbc/database)</jta-data-source>
>    <class>ch.entwine.captureagent.scheduler.RecordingEvent</class>
>    <class>ch.entwine.captureagent.config.ConfigOption</class>
>     
> <class>ch.entwine.captureagent.felix.configadmin.ConfigurationData</ 
> class>
>    <exclude-unlisted-classes>true</exclude-unlisted-classes>
>  </persistence-unit>
>
> </persistence>
>
> <blueprint default-activation="eager"
>  xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance

> "
>  xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0" xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0

> ">
>
>  <bean id="SchedulerService"  
> class="ch.entwine.captureagent.scheduler.Scheduler">
>    <jpa:context property="entityManager"  
> unitname="CaptureAgentCore" />
>    <tx:transaction method="*" value="Required" />
>  </bean>
>
>  <service ref="SchedulerService"  
> interface="ch.entwine.captureagent.scheduler.Scheduler" depends- 
> on="dataSource" />
> </blueprint>
> ====================
>
> I ran into the problem that the data source is not yet registered  
> when the JPA entity manager tries to get a reference to it. Error  
> message:
>
> 2012-04-19 16:17:38 ERROR (DelayedLookupDataSource:57) No JTA  
> datasource could be located using the JNDI name osgi:service/ 
> javax.sql.DataSource/(osgi.jndi.service.name=jdbc/database)
> javax.naming.NameNotFoundException: osgi:service/ 
> javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/database)"
>
> I've now tried to set the 'depends-on' attribute on the  
> SchedulerService definition in the blueprint file of bundle two (see  
> above). Unfortunately I get the following error now:
>
> 17:19:09 ERROR (BlueprintContainerImpl:348) Unable to start  
> blueprint container for bundle ch.entwine.matterhorn.core
> org.osgi.service.blueprint.container.ComponentDefinitionException:  
> Unresolved ref/idref to component: dataSource
>
> So, my question is how I can make sure the data source gets  
> registered before the JPA entity manager gets started?
>
>
> Thanks for your help!
> --
> Basil
>
>
>
>
>
>
> -- 
> Distributed Applications and Networks Area (DANA)
> FundaciĆ³ i2CAT, Internet i InnovaciĆ³ Digital a Catalunya, Barcelona, 
>  Spain
> T: +34 935 679 927 - http://dana.i2cat.net/

Mime
View raw message