Hi Guillaume,
The interfaces of the DataSource and XADatasource are well exposed
karaf@root> ls 249
FuseSource :: Webinars :: Fuse ESB & Persistence :: Database (249) provides:
----------------------------------------------------------------------------
objectClass = javax.sql.XADataSource
osgi.service.blueprint.compname = jta
service.id = 171
transactional = true
----
objectClass = javax.sql.DataSource
osgi.service.blueprint.compname = nonJTA
service.id = 172
transactional = false
----
objectClass = org.osgi.service.blueprint.container.BlueprintContainer
osgi.blueprint.container.symbolicname = database
osgi.blueprint.container.version = 1.0.0
service.id = 173
and aries jndi is deployed
karaf@root> list | grep -i jndi
[ 144] [Active ] [ ] [ ] [ 60] Apache Aries
JNDI API (0.2.0.incubating)
[ 145] [Active ] [ ] [ ] [ 60] Apache Aries
JNDI Core (0.2.0.incubating)
[ 146] [Active ] [ ] [ ] [ 60] Apache Aries
JNDI URL Handler (0.2.0.incubating)
BTW, I have made a small modification in the spring definition and now
openJPA is not able to cast a XADataSource !!
Persistence config
**********************
<persistence-unit name="reportincident" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>osgi:service/javax.sql.XADataSource/(transactional=true)</jta-data-source>
<!-- Required by openJPA to update sequence table outside of
Global Tx Management -->
<non-jta-data-source>osgi:service/javax.sql.DataSource/(transactional=false)</non-jta-data-source>
<class>com.fusesource.webinars.persistence.model.Incident</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<!-- openjpa & HSQLDB -->
<properties>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(SchemaAction='add,deleteTableContents')"/>
<property name="openjpa.Log"
value="commons"/>
<property name="openjpa.jdbc.DBDictionary"
value="hsql(useSchemaName=true)"/>
<property name="openjpa.jdbc.Schema"
value="PUBLIC"/>
<property name="openjpa.TransactionMode"
value="managed"/>
<property name="openjpa.ManagedRuntime"
value="jndi(TransactionManagerName=aries:services/javax.transaction.TransactionManager)"/>
<property name="openjpa.Multithreaded"
value="true"/>
<property name="openjpa.TransactionMode"
value="managed"/>
<property name="openjpa.ConnectionFactoryMode"
value="managed"/>
</properties>
</persistence-unit>
</persistence>
Spring config
***************
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="reportincident"/>
</bean>
Regards,
Charles
On Tue, Apr 12, 2011 at 3:43 PM, Guillaume Nodet <[email protected]> wrote:
> Looking at the stack trace, the problem seems to be in the JPA
> definition, as it does not hit the datasource.
> Can you list the services exported by the datasource bundle ?
> Also, do you have aries jndi installed ? As your config uses it to
> lookup the osgi service.
>
> On Tue, Apr 12, 2011 at 14:47, Charles Moulliard <[email protected]> wrote:
>> Here is the complete blueprint file to expose the datasource
>>
>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>>
>> xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
>>
>> <cm:property-placeholder persistent-id="database" id="database">
>> <cm:default-properties>
>>
>> <!-- JDBC Drivers -->
>> <cm:property name="jdbc.driverClassName"
>> value="org.hsqldb.jdbcDriver"/>
>> <cm:property name="jdbc.url"
>> value="jdbc:hsqldb:hsql://localhost/reportdb"/>
>> <cm:property name="jdbc.username" value="sa"/>
>> <cm:property name="jdbc.password" value=""/>
>>
>> <!-- Connection Pooling DBCP -->
>> <cm:property name="jdbc.initialSize" value="5"/>
>> <cm:property name="jdbc.maxActive" value="10"/>
>> <cm:property name="jdbc.maxIdle" value="10"/>
>> <cm:property name="jdbc.defaultAutoCommit" value="false"/>
>> <cm:property name="jdbc.removeAbandoned" value="false"/>
>> <cm:property name="jdbc.removeAbandonedTimeout" value="300"/>
>> <cm:property name="jdbc.logAbandoned" value="false"/>
>>
>> </cm:default-properties>
>> </cm:property-placeholder>
>>
>> <service auto-export="interfaces" ref="jta">
>> <service-properties>
>> <entry key="transactional" value="true"/>
>> </service-properties>
>> </service>
>>
>> <service auto-export="interfaces" ref="nonJTA">
>> <service-properties>
>> <entry key="transactional" value="false"/>
>> </service-properties>
>> </service>
>>
>> <!-- ###### JDBC Data Source ###### -->
>> <bean id="jta" class="org.enhydra.jdbc.standard.StandardXADataSource">
>> <property name="driverName" value="${jdbc.driverClassName}"/>
>> <property name="url" value="${jdbc.url}"/>
>> <property name="user" value="${jdbc.username}"/>
>> <property name="password" value="${jdbc.password}"/>
>> </bean>
>>
>> <bean class="org.apache.commons.dbcp.BasicDataSource" id="nonJTA">
>> <property name="driverClassName" value="${jdbc.driverClassName}"/>
>> <property name="url" value="${jdbc.url}"/>
>> <property name="username" value="${jdbc.username}"/>
>> <property name="password" value="${jdbc.password}"/>
>> <property name="initialSize" value="${jdbc.initialSize}"/>
>> <property name="maxActive" value="${jdbc.maxActive}"/>
>> <property name="maxIdle" value="${jdbc.maxIdle}"/>
>> <property name="defaultAutoCommit" value="false"/>
>> <property name="removeAbandoned" value="${jdbc.removeAbandoned}"/>
>> <property name="removeAbandonedTimeout"
>> value="${jdbc.removeAbandonedTimeout}"/>
>> <property name="logAbandoned" value="${jdbc.logAbandoned}"/>
>> </bean>
>>
>> </blueprint>
>>
>> Regards,
>>
>> Charles
>>
>>
>> On Tue, Apr 12, 2011 at 2:37 PM, Ioannis Canellos <[email protected]> wrote:
>>> Halo Charles,
>>>
>>> I think that you didn't paste the actual data source.
>>>
>>>
>>> On Tue, Apr 12, 2011 at 3:20 PM, Charles Moulliard
>>> <[email protected]>wrote:
>>>
>>>> Hi,
>>>>
>>>> I have configured OpenJPA to use a JTA/XA Datasource on ServiceMix but
>>>> when I try to insert data in the DB, openJPA generates the following
>>>> error :
>>>>
>>>> Caused by: java.lang.RuntimeException: There were errors initializing
>>>> your configuration: <openjpa-2.1.0-r422266:1071316 fatal user error>
>>>> org.apache.openjpa.util.UserException: A JDBC Driver or DataSource
>>>> class name must be specified in the ConnectionDriverName property.
>>>> at
>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:76)
>>>> at
>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)
>>>> at
>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getConnectionFactory(JDBCConfigurationImpl.java:732)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>> at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>> at java.lang.reflect.Method.invoke(Method.java:597)
>>>> at
>>>> org.apache.openjpa.lib.conf.ConfigurationImpl.instantiateAll(ConfigurationImpl.java:295)
>>>>
>>>>
>>>> The property
>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(transactional=true)</jta-datasource>
>>>> in the persistence.xml file point to the XADataSource exposed as an
>>>> osgi service
>>>>
>>>> Persistence
>>>> **************
>>>> <persistence-unit name="reportincident" transaction-type="JTA">
>>>>
>>>>
>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>
>>>>
>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>
>>>>
>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(transactional=true)</jta-data-source>
>>>> <!-- Required by openJPA to update sequence table outside of
>>>> Global Tx Management -->
>>>>
>>>> <non-jta-data-source>osgi:service/javax.sql.DataSource/(transactional=false)</non-jta-data-source>
>>>>
>>>> <class>com.mycompany.persistence.model.Incident</class>
>>>>
>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>
>>>> <!-- openjpa & HSQLDB -->
>>>> <properties>
>>>> <property name="openjpa.jdbc.SynchronizeMappings"
>>>>
>>>> value="buildSchema(SchemaAction='add,deleteTableContents')"/>
>>>> <property name="openjpa.Log"
>>>> value="commons"/>
>>>> <property name="openjpa.jdbc.DBDictionary"
>>>> value="hsql(useSchemaName=true)"/>
>>>> <property name="openjpa.jdbc.Schema"
>>>> value="PUBLIC"/>
>>>> <property name="openjpa.TransactionMode"
>>>> value="managed"/>
>>>> <property name="openjpa.ManagedRuntime"
>>>>
>>>>
>>>> value="jndi(TransactionManagerName=aries:services/javax.transaction.TransactionManager)"/>
>>>> <property name="openjpa.Multithreaded"
>>>> value="true"/>
>>>> <property name="openjpa.TransactionMode"
>>>> value="managed"/>
>>>> <!--<property name="openjpa.ConnectionFactoryMode"
>>>> value="managed"/>-->
>>>> </properties>
>>>>
>>>>
>>>>
>>>> Blueprint config of the DataSource
>>>> ****************************************
>>>> <service auto-export="interfaces" ref="jta">
>>>> <service-properties>
>>>> <entry key="transactional" value="true"/>
>>>> </service-properties>
>>>> </service>
>>>>
>>>> <service auto-export="interfaces" ref="jta">
>>>> <service-properties>
>>>> <entry key="transactional" value="true"/>
>>>> </service-properties>
>>>> </service>
>>>>
>>>> Any idea is welcome.
>>>>
>>>>
>>>> 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
>>>>
>>>
>>>
>>>
>>> --
>>> *Ioannis Canellos*
>>> *
>>> http://iocanel.blogspot.com
>>>
>>> Apache Karaf <http://karaf.apache.org/> Committer & PMC
>>> Apache ServiceMix <http://servicemix.apache.org/> Committer
>>> *
>>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>