Re: Migration to Karaf 4.0.1
Hi Christian: karaf@root()> service:list EntityManagerFactory [javax.persistence.EntityManagerFactory] osgi.unit.name = salazarJPA osgi.unit.provider = org.hibernate.jpa.HibernatePersistenceProvider osgi.unit.version = 0.0.1 service.bundleid = 168 service.id = 206 service.scope = singleton Provided by : DataBaseService (168) For some reason if I change to Hibernate 4.2.15 the EntityManagerFactory not registry. On the other hand, I know the EntityManger not injected because an exception occurs when using it (it is null). -- View this message in context: http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982p4043016.html Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Migration to Karaf 4.0.1
I think this can be caused by persistence api 2.0 and 2.1 being installed at the same time. Normally karaf should make sure only one is installed but in some circumstances this can happen. In this case hibernate will publish the PersistenceProvider with the 2.0 package version while Aries JPA will look for a service on the 2.1 package. So it will not find it. Aries JPA 2.1.0 has the issue that it injects a proxy to the EntityManagerFactory regardless if it is there. The new Aries JPA 2.2.0 version should correctly handle this so the bundle is only started when the EntityManagerFactory is actually there. Unfortunately I just found an issue with the new version. https://issues.apache.org/jira/browse/ARIES-1430 Christian On 11.10.2015 21:17, conejo wrote: Hi Christian: karaf@root()> service:list EntityManagerFactory [javax.persistence.EntityManagerFactory] osgi.unit.name = salazarJPA osgi.unit.provider = org.hibernate.jpa.HibernatePersistenceProvider osgi.unit.version = 0.0.1 service.bundleid = 168 service.id = 206 service.scope = singleton Provided by : DataBaseService (168) For some reason if I change to Hibernate 4.2.15 the EntityManagerFactory not registry. On the other hand, I know the EntityManger not injected because an exception occurs when using it (it is null). -- View this message in context: http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982p4043016.html Sent from the Karaf - User mailing list archive at Nabble.com. -- Christian Schneider http://www.liquid-reality.de Open Source Architect http://www.talend.com
Re: Migration to Karaf 4.0.1
Hello Christian. You guessed right! I have added: Persistence API mvn: org.hibernate.javax.persistence / hibernate-jpa-2.1-api / 1.0.0.Final And I put my pom: org.hibernate.javax.persistence hibernate-jpa-2.1-api 1.0.0.Final With this works fine. Thank you very much for the assistance. -- View this message in context: http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982p4043019.html Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Migration to Karaf 4.0.1
Anyway a datasource using blueprint should work as well. Regards JB On 10/10/2015 08:54 AM, Christian Schneider wrote: 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: * http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0;> 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. -- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com
Re: Migration to Karaf 4.0.1
Generally speaking, the JDBC feature in Karaf 4 is a change compared to Karaf 3. We should document better (I started to update documentation yesterday). Due to the lack of documentation, it's not easy at all for end users to use JDBC in Karaf 4: it's not obvious that pax-jdbc should be installed, the config created from the factory should be explained, the JDBC datasources described using blueprint (as in Karaf 3) are still valid, but not well supported in the jdbc commands, etc. My goal is to improve this for 4.0.3. Regards JB On 10/10/2015 12:15 AM, conejo wrote: Hello Christian. Thanks for your help. *My DataSource is in the deploy folder and has the following contents: * http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0;> 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. -- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com
Re: Migration to Karaf 4.0.1
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: * http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0;> 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.
Re: Migration to Karaf 4.0.1
Hello Christian. Thanks for your help. *My DataSource is in the deploy folder and has the following contents: * http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0;> 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.
Re: Migration to Karaf 4.0.1
Hi, what's the JPA engine ? Did you install at runtime the jpa, and jpa engine features ? Regards JB On 10/09/2015 12:33 PM, conejo wrote: Hello. I have an application that runs on Karaf 3.0.3 and would like to migrate to Karaf 4.0.1. The main problem I have with the migration of data service: I do not get that blueprint inject the EntityManager. *This is my pom:* dataService 0.0.1 bundle DataBaseService Servicio de base de datos. org.apache.maven.plugins maven-compiler-plugin 3.1 1.7 1.7 org.apache.felix maven-bundle-plugin 2.5.4 true true salazarDB ${project.version} META-INF/persistence.xml es.salazaryasociados.db.*;version=${project.version} * *, org.hibernate.proxy, javassist.util.proxy org.apache.geronimo.specs geronimo-jpa_2.0_spec 1.1 provided org.hibernate hibernate-validator 5.0.3.Final provided javax.inject javax.inject 1 true javax.transaction javax.transaction-api 1.2 *And this is the definition of the service:* http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:jpa="http://aries.apache.org/xmlns/jpan/v1.0.0; xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; > And finally the class: @Transactional public class DataService implements IDataService { private ClientDao clientDao; private ExpedienteDao fileDao; private ResponsableDao responsableDao; private UserDao userDao; private PagoDao pagoDao; private DocumentoDao documentoDao; @PersistenceContext(unitName="salazarJPA") EntityManager entityManager; public EntityManager getEntityManager() { return entityManager; } public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } I've been mulling over time and can not see why not inject the EntityManager blueprint. Can you help me? Thank you. -- View this message in context: http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982.html Sent from the Karaf - User mailing list archive at Nabble.com. -- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com
Migration to Karaf 4.0.1
Hello. I have an application that runs on Karaf 3.0.3 and would like to migrate to Karaf 4.0.1. The main problem I have with the migration of data service: I do not get that blueprint inject the EntityManager. *This is my pom:* dataService 0.0.1 bundle DataBaseService Servicio de base de datos. org.apache.maven.plugins maven-compiler-plugin 3.1 1.7 1.7 org.apache.felix maven-bundle-plugin 2.5.4 true true salazarDB ${project.version} META-INF/persistence.xml es.salazaryasociados.db.*;version=${project.version} * *, org.hibernate.proxy, javassist.util.proxy org.apache.geronimo.specs geronimo-jpa_2.0_spec 1.1 provided org.hibernate hibernate-validator 5.0.3.Final provided javax.inject javax.inject 1 true javax.transaction javax.transaction-api 1.2 *And this is the definition of the service:* http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:jpa="http://aries.apache.org/xmlns/jpan/v1.0.0; xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; > And finally the class: @Transactional public class DataService implements IDataService { private ClientDao clientDao; private ExpedienteDao fileDao; private ResponsableDao responsableDao; private UserDao userDao; private PagoDao pagoDao; private DocumentoDao documentoDao; @PersistenceContext(unitName="salazarJPA") EntityManager entityManager; public EntityManager getEntityManager() { return entityManager; } public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } I've been mulling over time and can not see why not inject the EntityManager blueprint. Can you help me? Thank you. -- View this message in context: http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982.html Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Migration to Karaf 4.0.1
Hello. Thanks for the help. I think. I installed the JPA, transaction and Hibernate 4.3.6.Final features. And this is my persistence.xml http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd; xmlns = "http://java.sun.com/xml/ns/persistence; xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance; version = "2.0"> org.apache.openjpa.persistence.PersistenceProviderImpl org.hibernate.jpa.HibernatePersistenceProvider osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/gestords) es.salazaryasociados.db.model.Cliente es.salazaryasociados.db.model.Documento es.salazaryasociados.db.model.Expediente es.salazaryasociados.db.model.Pago es.salazaryasociados.db.model.Responsable es.salazaryasociados.db.model.User es.salazaryasociados.db.model.Role AUTO -> The service is installed: 185 [es.salazar asociados.db.service.IDataService] salazarDB (168) And also the persistence unit: 200 [javax.persistence.EntityManagerFactory] salazarDB (168) -- View this message in context: http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982p4042984.html Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Migration to Karaf 4.0.1
Can you post the log? You should see that Aries JPA find the peristence unit bundle, searches and finds the PersistenceProvider and then searches and finds the DataSource. Only when all are present the inject will be done. Btw. You should consider to update to Karaf 4.0.2 soon as it fixes some bugs with jpa. How do you create the DataSource? Christian On 09.10.2015 12:33, conejo wrote: Hello. I have an application that runs on Karaf 3.0.3 and would like to migrate to Karaf 4.0.1. The main problem I have with the migration of data service: I do not get that blueprint inject the EntityManager. *This is my pom:* dataService 0.0.1 bundle DataBaseService Servicio de base de datos. org.apache.maven.plugins maven-compiler-plugin 3.1 1.7 1.7 org.apache.felix maven-bundle-plugin 2.5.4 true true salazarDB ${project.version} META-INF/persistence.xml es.salazaryasociados.db.*;version=${project.version} * *, org.hibernate.proxy, javassist.util.proxy org.apache.geronimo.specs geronimo-jpa_2.0_spec 1.1 provided org.hibernate hibernate-validator 5.0.3.Final provided javax.inject javax.inject 1 true javax.transaction javax.transaction-api 1.2 *And this is the definition of the service:* http://www.osgi.org/xmlns/blueprint/v1.0.0; xmlns:jpa="http://aries.apache.org/xmlns/jpan/v1.0.0; xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; > And finally the class: @Transactional public class DataService implements IDataService { private ClientDao clientDao; private ExpedienteDao fileDao; private ResponsableDao responsableDao; private UserDao userDao; private PagoDao pagoDao; private DocumentoDao documentoDao; @PersistenceContext(unitName="salazarJPA") EntityManager entityManager; public EntityManager getEntityManager() { return entityManager; } public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } I've been mulling over time and can not see why not inject the EntityManager blueprint. Can you help me? Thank you. -- View this message in context: http://karaf.922171.n3.nabble.com/Migration-to-Karaf-4-0-1-tp4042982.html Sent from the Karaf - User mailing list archive at Nabble.com. -- Christian Schneider http://www.liquid-reality.de Open Source Architect http://www.talend.com