I cannot seem to get OpenJPA and MySQL to work in Aries. I use Aries 0.2-incubating, OpenJPA 2.0.1 and the 5.1.13 version of MySQL's JDBC driver.
I have no problems connecting to MySQL outside of OSGi but cannot get it to work in OSGi. BTW I mostly use PaxExam for the Aries tests and I run on Felix 2.0.0. My persistence.xml looks as follows: <?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="refdataPU" transaction-type="JTA"> > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <jta-data-source>osgi:services/javax.sql.DataSource/( > osgi.jndi.service.name=jdbc/refdatajta)</jta-data-source> <class>se.digia.sts.refdata.domain.Account</class> <class>se.digia.sts.refdata.domain.BusinessUnit</class> <class>se.digia.sts.persistence.EntityBase</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="openjpa.Connection2URL" > value="jdbc:mysql://localhost:3306/refdata" /> <property name="openjpa.Connection2DriverName" > value="com.mysql.jdbc.Driver" /> <property name="openjpa.Connection2UserName" value="someuser" /> <property name="openjpa.Connection2Password" value="somepassword" /> <property name="openjpa.ConnectionFactoryMode" value="managed" /> <property name="openjpa.jdbc.SynchronizeMappings" > value="buildSchema(ForeignKeys=true)" /> <property name="openjpa.jdbc.DBDictionary" > value="org.apache.openjpa.jdbc.sql.MySQLDictionary" /> <property name="openjpa.jdbc.UpdateManager" value="operation-order" /> <property name="openjpa.Log" value="DefaultLevel=TRACE, Tool=INFO" /> </properties> </persistence-unit> </persistence> and the blueprint for my datasource looks as follows: <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi=" > http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0" > default-activation="lazy"> > <bean id="refdataXADataSource" > class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"> <property name="user" value="someuser" /> <property name="password" value="somepassword" /> <property name="URL" value="jdbc:mysql://localhost:3306/refdata" /> <!-- <property name="driverClassName" value="com.mysql.jdbc.Driver" > />--> <!-- <property name="url" value="jdbc:mysql://localhost:3306/refdata" > />--> </bean> > <service ref="refdataXADataSource" interface="javax.sql.XADataSource"> <service-properties> <entry key="osgi.jndi.service.name" value="jdbc/refdatajta" /> </service-properties> </service> </blueprint> I get the following exception: <openjpa-2.0.1-r422266:989424 nonfatal general error> > org.apache.openjpa.persistence.PersistenceException: There were errors > initializing your configuration: <openjpa-2.0.1-r422266:989424 fatal user > error> org.apache.openjpa.util.UserException: A connection could not be > obtained for driver class "null" and URL "null". You may have specified an > invalid URL. at > org.apache.openjpa.jdbc.schema.DataSourceFactory.newConnectException(DataSourceFactory.java:261) at > org.apache.openjpa.jdbc.schema.DataSourceFactory.installDBDictionary(DataSourceFactory.java:247) at > org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:728) I've tried numerous ways to configure the MysqlXADataSource to no avail. Seems like this must be a very common combination which leads me to hope that someone can help me out. The only samples I've seen in combination with Aries uses a Derby database that doesn't seem to need any configuration. I don't think there is anything wrong with the actual settings (user, password, URL) since they work perfectly outside of OSGi. However, the settings don't seem to get to the data source. I've probably not fully understood how this works. My next step would be to somehow configure a connection pool but it seems like just getting things to work occupies most of time right now. Any clues? /Bengt
