The problem is that you probably have the persistence.xml and the entity classes in the same bundle.

See:
https://issues.apache.org/jira/browse/ARIES-1433

Aries JPA container watches for bundles with the Meta-Persistence header. If the bundle enters Starting or Active state then Aries JPA creates the EntityManagerFactory and adds it as a service in the name of the bundle.

The problem is now that if you also have the bean that uses the EntityManagerFactory in the same bundle then blueprint will never start up. Apparently this denies the bundle to enter the Starting or Active state.
So Aries JPA will never publish the EntityManagerFactory.

I am not sure if we can fix this. So the best practice is to always separate the persistence unit bundle from bundles using the EnityManager.

Christian

On 13.11.2015 14:01, conejo wrote:
Hello.
I have a problem with a simple service. This service is created using
blueprint with the following file:

<?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/jpan/v1.0.0";
     xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.2.0";
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     >
        
        <jpa:enable/>                     
        <service ref="ornitodataservice2"
                
interface="org.llaroqui.ornitorrinco.data.service.api.IDataService" />
                
        <bean id="ornitodataservice2"
class="org.llaroqui.ornitorrinco.data.service.impl.DataService">
                <property name="theDao" ref="dao"/>
                <tx:transaction method="*" value="Required" />
        </bean>
                
        <bean id="dao"
                class="org.llaroqui.ornitorrinco.data.service.impl.Dao">
        </bean>                                   
</blueprint>

The problem is that if I include it in the jar (in the OSGI-INF / blueprint
folder) the service does not appear in the list of services but if I do
leave the file in deploy folder, the service appears.

If I do both, the log tells me:

Bundle service-impl/0.0.1 is waiting for dependencies
[(&(osgi.unit.name=ornitoJPA)(objectClass=javax.persistence.EntityManager))]

(I change the service id).



--
View this message in context: 
http://karaf.922171.n3.nabble.com/4-0-3-Karaf-JPA-problem-tp4043497.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

Reply via email to