Hi, I had the same problem. After some debugging it seemed to me that aries-jpa code should be modified a bit to wait for the datasource to be available.
Import-Service in manifest.mf did not help. As much as I remember Import-Service is only for information but it does nothing in OSGI containers. Blueprint also did not work as the BlueprintContainer for a bundle starts up when the bundle is already active. At that time JPAExtender picks up the bundle before the necessary service is ready. On the end I modified my code in the way that the persistence.xml contained the connection info of the database. In this case a DataSourceFactory service of the JDBC driver is necessary for the PersistenceUnit to load. Well, I solved it by putting an Import-Package onto the bundle that contained the DataSourceFactory service for my JDBC driver however it is not a nice solution. I created an issue at https://issues.apache.org/jira/browse/ARIES-840 that is related to this topic. Regards, Balazs Zsoldos Software Architect Mobile: +36-70/594-92-34 Everit Kft. https://www.everit.biz On Fri, Apr 20, 2012 at 5:29 PM, Christian Schneider < [email protected]> wrote: > I think having a > Import-Service: javax.sql.DataSource > in the Manifest. The maven bundle plugin should do this. > > So blueprint will make sure the service is there. > > Christian > > Am 19.04.2012 17:34, schrieb Brunner Basil: > > 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<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<http://java.sun.com/xml/ns/persistence> >> " >> >> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<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 <http://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<http://www.osgi.org/xmlns/blueprint/v1.0.0>" >> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance> >> " >> >> xmlns:jpa="http://aries.**apache.org/xmlns/jpa/v1.0.0<http://aries.apache.org/xmlns/jpa/v1.0.0>" >> xmlns:tx="http://aries.apache.**org/xmlns/transactions/v1.0.0<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 <http://osgi.jndi.service.name> >> =jdbc/database) >> javax.naming.**NameNotFoundException: osgi:service/javax.sql.** >> DataSource/"(osgi.jndi.**service.name <http://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! >> > > > -- > Christian Schneider > http://www.liquid-reality.de > > Open Source Architect > Talend Application Integration Division http://www.talend.com > >
