I'm trying to configure a datasource for mysql and a corresp. persistence bundle on top of Apache Aries. This is the datasource's blueprint file
<bean id="mysqlDataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<property name="url" value="jdbc:mysql://matteos-mbp:3306/" />
<property name="user" value="root" />
<property name="password" value="root" />
<property name="databaseName" value="testDBBlueprint" />
<property name="createDatabaseIfNotExist" value="true" />
</bean>
<bean id="mysqlXADataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<property name="url" value="jdbc:mysql://matteos-mbp:3306/" />
<property name="user" value="root" />
<property name="password" value="root" />
<property name="databaseName" value="testDBBlueprint" />
<property name="createDatabaseIfNotExist" value="true" />
</bean>
<service ref="mysqlDataSource" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/ddauthdb" />
</service-properties>
</service>
<service ref="mysqlXADataSource" interface="javax.sql.XADataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/xaddauthdb" />
</service-properties>
</service>
and these are the persistence.xml and the blueprint.xml files for the entities/persistence bundle (bundle com.mycompany.jpa.auth.entities):
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ddauth">
<jta-data-source>
osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/xaddauthdb)
</jta-data-source>
<non-jta-data-source>
osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/ddauthdb)
</non-jta-data-source>
<class>com.mycompany.persistence.users.TestUser</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property
name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
</properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
<bean id="userService" class="com.mycompany.persistence.users.UserServiceImpl">
<tx:transaction method="*" value="Required" />
<jpa:context property="entityManager" unitname="ddauth"/>
</bean>
<bean
id="populator"
class="com.mycompany.persistence.users.Populator"
init-method="populate"
activation="eager" >
<property
name="userService"
ref="userService" />
</bean>
<service ref="userService" interface="com.mycompany.users.api.UserService" />
</blueprint>
The error I get is
org.ops4j.pax.logging.pax-logging-api[org.apache.aries.blueprint.container.BlueprintContainerImpl] : Unable to start blueprint container for bundle com.mycompany.jpa.auth.entities due to unresolved dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=ddauth))(objectClass=javax.persistence.EntityManagerFactory))]
java.util.concurrent.TimeoutException
at org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:336)
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
org.ops4j.pax.logging.pax-logging-api[org.apache.aries.blueprint.container.BlueprintEventDispatcher] : Sending blueprint container event BlueprintEvent[type=FAILURE, dependencies=[(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=ddauth))(objectClass=javax.persistence.EntityManagerFactory))], exception=null] for bundle com.mycompany.jpa.auth.entities
My runtime is the following:
START LEVEL 1
ID|State |Level|Name
0|Active | 0|OSGi System Bundle (3.10.2.v20150203-1939)
1|Active | 1|aQute.xray.plugin (1.7.0.201403241317)
2|Active | 1|com.mycompany.db.mysql.auth (0.0.0.201506180714)
3|Active | 1|Oracle Corporation's JDBC Driver for MySQL (5.1.35)
4|Active | 1|Apache Commons Collections (3.2.1)
5|Active | 1|Apache Aries Blueprint Bundle (1.1.0)
6|Active | 1|Apache Aries Blueprint API (1.0.1)
7|Active | 1|Apache Aries Blueprint Core (1.4.2)
8|Active | 1|Aries JPA Container API (1.0.2)
9|Active | 1|Aries JPA Container blueprint integration for Aries blueprint (1.0.4)
10|Active | 1|Aries JPA Container (1.0.2)
11|Active | 1|Aries JPA Container Managed Contexts (1.0.4)
12|Active | 1|Apache Aries Proxy API (1.0.1)
13|Active | 1|Apache Aries Proxy Service (1.0.4)
14|Active | 1|Apache Aries Transaction Blueprint (1.0.2)
15|Active | 1|Apache Aries Transaction Manager (1.0.0)
16|Active | 1|Apache Aries Transaction Manager (1.1.1)
17|Active | 1|Apache Aries Util (1.1.0)
18|Active | 1|Commons Lang (2.6.0)
19|Active | 1|Commons Pool (1.6.0)
20|Active | 1|Apache CXF Core (3.1.1)
21|Active | 1|Apache CXF Runtime HTTP Transport (3.1.1)
22|Active | 1|Apache Felix Configuration Admin Service (1.8.0)
23|Active | 1|Apache Felix Gogo Command (0.14.0)
24|Active | 1|Apache Felix Gogo Runtime (0.12.1)
25|Active | 1|Apache Felix Gogo Shell (0.10.0)
26|Active | 1|Apache Felix Metatype Service (1.0.10)
27|Active | 1|Apache Felix Declarative Services (1.8.2)
28|Active | 1|Apache Felix Web Management Console (3.1.8)
29|Active | 1|Apache Geronimo JSR-317 JPA 2.0 Spec API (1.1.0)
30|Active | 1|geronimo-jta_1.1_spec (1.1.1)
31|Active | 1|OpenJPA Aggregate Jar (2.2.2)
32|Active | 1|Apache ServiceMix :: Bundles :: commons-dbcp (1.4.0.3)
33|Active | 1|XmlSchema Core (2.2.1)
34|Active | 1|Apache XBean OSGI Bundle Utilities (3.18.0)
35|Active | 1|Apache XBean :: Classpath Resource Finder (3.18.0)
36|Active | 1|hibernate-jpa-2.1-api (1.0.0.Final)
37|Active | 1|ASM all classes with debug info (5.0.3)
38|Active | 1|OPS4J Pax Logging - API (1.8.2)
39|Active | 1|OPS4J Pax Web - Jetty Bundle (4.1.2)
40|Active | 1|com.mycompany.jpa.auth.entities (0.0.0.201506180718)
Could you help me spotting what is missing here? What is the best approach to debug this kind of situation?
Thanks.
The problem was due to a fistful of missing bundles in my runtime. To solve the problem it was enough to look at the blog sample project within the Apache Aries Samples and replicate that runtime in my bnd file.
The bundles I added are the following: