Your DataSource is not ready for JTA. This will cause your transactions to not work correctly. You should use pax-jdbc instead of blueprint to create the
DataSource it will make sure you have a production ready DataSource.

See:
https://ops4j1.jira.com/wiki/display/PAXJDBC/Create+DataSource+from+config
https://ops4j1.jira.com/wiki/display/PAXJDBC/Pooling+and+XA+support+for+DataSourceFactory
http://liquid-reality.de/display/liquid/2015/03/05/Apache+Karaf+Tutorial+Part+9+-+Annotation+based+blueprint+and+JPA

The log shows that Aries JPA finds the PersistenceProvider and the DataSource and registers the EntityManagerFactory. So that all seems to work. You should also be able to validate this by doing "service:list EntityManagerFactory".

One possible problem is that you use the jpa 2.0 api in your project. If you use hibernate 4.3 then you might need the 2.1 version.
You can check my tutorial project for the dependencies and setup it uses.

Btw. how do you see that the EntityManager is not injected?

Christian

Am 10.10.2015 um 00:15 schrieb conejo:
Hello Christian. Thanks for your help.

*My DataSource is in the deploy folder and has the following contents:
*

<?xml version="1.0" encoding="UTF-8"?>


<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";      
                   
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";>

        <cm:property-placeholder persistent-id="GestorConfig"
update-strategy="reload">
                <cm:default-properties>
                        <cm:property name="db.url"
                        
value="jdbc:hsqldb:file:C:/Desarrollo/Pruebas/SalazarYAsociados/OSGI_Version/BBDD/hsqldb/salazar"
/>
                </cm:default-properties>
        </cm:property-placeholder>

        <bean id="dataSource" class="org.hsqldb.jdbc.JDBCDataSource">
                <property name="url" value="${db.url}" />
                <property name="user" value="salazar" />
                <property name="password" value="salazar" />
                
        </bean>
        
        <service interface="javax.sql.DataSource" ref="dataSource">
                <service-properties>
                        <entry key="osgi.jndi.service.name" value="jdbc/gestords" 
/>
                </service-properties>
        </service>
</blueprint>

On the other hand the data service (salazarDB) is a service that is
installed as part of the distribution (it's in the system folder, if I'm not
mistaken).

*In the log the following lines appear:*

2015-10-09 23:53:12,851 | INFO  | pool-2-thread-1  |
PersistenceBundleTracker         | 38 - org.apache.aries.jpa.container -
2.1.0 | Found persistence unit salazarJPA in bundle salazarDB with provider
org.hibernate.jpa.HibernatePersistenceProvider.
2015-10-09 23:53:12,867 | INFO  | pool-2-thread-1  |
PersistenceProviderTracker       | 38 - org.apache.aries.jpa.container -
2.1.0 | Found provider for salazarJPA
org.hibernate.jpa.HibernatePersistenceProvider

2015-10-09 23:53:13,165 | INFO  | pool-2-thread-1  | DataSourceTracker
| 38 - org.apache.aries.jpa.container - 2.1.0 | Tracking DataSource for
punit salazarJPA with filter
(&(objectClass=javax.sql.DataSource)(osgi.jndi.service.name=jdbc/gestords))
2015-10-09 23:53:13,165 | INFO  | pool-2-thread-1  | DataSourceTracker
| 38 - org.apache.aries.jpa.container - 2.1.0 | Found DataSource for
salazarJPA
osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/gestords)
2015-10-09 23:53:13,165 | INFO  | jpa.salazarJPA]) | ManagedEMF
| 38 - org.apache.aries.jpa.container - 2.1.0 | Registering
EntityManagerFactory for persistence unit salazarJPA


*If you need the full log I can provide it for. You tell me.*

I can wait for version 4.0.2, if not much delay. We are evaluating it Karaf
for a larger project and the possibility of using JPA 2.0 seems more
attractive.



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982p4042990.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to