aries-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (ARIES-1160) Hibernate JPA: EntityManagerFactoryManager failed to create EntityManagerFactories by Bundle.RESOLVED
Date Fri, 24 Oct 2014 12:21:34 GMT

     [ https://issues.apache.org/jira/browse/ARIES-1160?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Guillaume Nodet updated ARIES-1160:
-----------------------------------
    Description: 
Use case: persistence bundle is deployed in OSGi using Hibernate persistence provider. Bundle
contains blueprint configuration injecting EntityManager and activates transaction management:
{code}
<blueprint  xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
            xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">

  <bean id="addressDao" class="de.conrad.ccp.basit.customer.ecom.dao.impl.AddressDaoImpl">

      <jpa:context unitname="ecom" property="entityManager"/>
      <tx:transaction method="*" value="Required"/>
  </bean>
  
  <service ref="addressDao" interface="de.conrad.ccp.basit.entity.customer.ecom.dao.AddressDao"
/>
  
</blueprint>
{code}

Effect: bundle waiting for EntityManager service. The reason of problem is runtime exception
by providerService.createContainerEntityManagerFactory(mpui.getPersistenceUnitInfo(), mpui.getContainerProperties()).
Exception is unfortunately not logged by Aries. The stack trace is following:
{code}
java.lang.IllegalStateException: The bundle de.conrad.poc.customerservice-ecom/0.0.1.SNAPSHOT
is not started.
        at org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(JndiDataSource.java:61)
        at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36)
        at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)
        at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132)
        at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783)
        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
        at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:99)
        at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:330)
        at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:175)
        at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingService(PersistenceBundleManager.java:197)
{code}

The problem is that call of createEntityManagerFactories() in EntityManagerFactoryManager.bundleStateChange()
is made by BUNDLE.RESOLVED event.
The lookup of data source is failed, because the bundle context is not yet available (call
by BUNDLE.RESOLVED event). The createEntityManagerFactory is called again by Bundle.ACTIVE
event, the problem is that emfs hash map is already created, but it is empty.
Therefore  STARTED/ACTIVE createEntityManagerFactories() is called, but makes nothing.

Attached patch contains two changes:
a) log runtime exception throwing by providerService.createContainerEntityManagerFactory
b) adds check to empty hash map:
if(((emfs == null) || emfs.isEmpty()) && !quiesce)
The patch fixes the problem.

Basically it should analyzed is call createEntityManagerFactories() really necessary for Bundle.RESOLVED
event. 




  was:
Use case: persistence bundle is deployed in OSGi using Hibernate persistence provider. Bundle
contains blueprint configuration injecting EntityManager and activates transaction management:
<blueprint  xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
            xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">

  <bean id="addressDao" class="de.conrad.ccp.basit.customer.ecom.dao.impl.AddressDaoImpl">

      <jpa:context unitname="ecom" property="entityManager"/>
      <tx:transaction method="*" value="Required"/>
  </bean>
  
  <service ref="addressDao" interface="de.conrad.ccp.basit.entity.customer.ecom.dao.AddressDao"
/>
  
</blueprint>

Effect: bundle waiting for EntityManager service. The reason of problem is runtime exception
by providerService.createContainerEntityManagerFactory(mpui.getPersistenceUnitInfo(), mpui.getContainerProperties()).
Exception is unfortunately not logged by Aries. The stack trace is following:
{code}
java.lang.IllegalStateException: The bundle de.conrad.poc.customerservice-ecom/0.0.1.SNAPSHOT
is not started.
        at org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(JndiDataSource.java:61)
        at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36)
        at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242)
        at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)
        at org.hibernate.service.internal.StandardServiceRegistryImpl.configureS
ervice(StandardServiceRegistryImpl.java:76)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initialize
Service(AbstractServiceRegistryImpl.java:160)
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService
(AbstractServiceRegistryImpl.java:132)
        at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.
java:1825)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1783)
        at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
        at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:99)
        at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:330)
        at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:175)
        at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingService(PersistenceBundleManager.java:197)
{code}

The problem is that call of createEntityManagerFactories() in EntityManagerFactoryManager.bundleStateChange()
is made by BUNDLE.RESOLVED event.
The lookup of data source is failed, because the bundle context is not yet available (call
by BUNDLE.RESOLVED event). The createEntityManagerFactory is called again by Bundle.ACTIVE
event, the problem is that emfs hash map is already created, but it is empty.
Therefore  STARTED/ACTIVE createEntityManagerFactories() is called, but makes nothing.

Attached patch contains two changes:
a) log runtime exception throwing by providerService.createContainerEntityManagerFactory
b) adds check to empty hash map:
if(((emfs == null) || emfs.isEmpty()) && !quiesce)
The patch fixes the problem.

Basically it should analyzed is call createEntityManagerFactories() really necessary for Bundle.RESOLVED
event. 





> Hibernate JPA: EntityManagerFactoryManager failed to create EntityManagerFactories by
Bundle.RESOLVED
> -----------------------------------------------------------------------------------------------------
>
>                 Key: ARIES-1160
>                 URL: https://issues.apache.org/jira/browse/ARIES-1160
>             Project: Aries
>          Issue Type: Bug
>          Components: JPA
>    Affects Versions: 1.0
>         Environment: OSGi
>            Reporter: Andrei Shakirin
>            Assignee: Sergey Beryozkin
>             Fix For: 1.0.1-SNAPSHOT
>
>         Attachments: ARIES-1160-2.patch, aries-jpa-1.0.0-ARIES-1160.patch, org.apache.aries.jpa.container.patch
>
>
> Use case: persistence bundle is deployed in OSGi using Hibernate persistence provider.
Bundle contains blueprint configuration injecting EntityManager and activates transaction
management:
> {code}
> <blueprint  xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
>             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>             xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0"
>             xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0">
>   <bean id="addressDao" class="de.conrad.ccp.basit.customer.ecom.dao.impl.AddressDaoImpl">

>       <jpa:context unitname="ecom" property="entityManager"/>
>       <tx:transaction method="*" value="Required"/>
>   </bean>
>   
>   <service ref="addressDao" interface="de.conrad.ccp.basit.entity.customer.ecom.dao.AddressDao"
/>
>   
> </blueprint>
> {code}
> Effect: bundle waiting for EntityManager service. The reason of problem is runtime exception
by providerService.createContainerEntityManagerFactory(mpui.getPersistenceUnitInfo(), mpui.getContainerProperties()).
> Exception is unfortunately not logged by Aries. The stack trace is following:
> {code}
> java.lang.IllegalStateException: The bundle de.conrad.poc.customerservice-ecom/0.0.1.SNAPSHOT
is not started.
>         at org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(JndiDataSource.java:61)
>         at org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36)
>         at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70)
>         at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242)
>         at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)
>         at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76)
>         at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160)
>         at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132)
>         at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825)
>         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783)
>         at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
>         at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
>         at org.hibernate.osgi.OsgiPersistenceProvider.createContainerEntityManagerFactory(OsgiPersistenceProvider.java:99)
>         at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.createEntityManagerFactories(EntityManagerFactoryManager.java:330)
>         at org.apache.aries.jpa.container.impl.EntityManagerFactoryManager.bundleStateChange(EntityManagerFactoryManager.java:175)
>         at org.apache.aries.jpa.container.impl.PersistenceBundleManager.addingService(PersistenceBundleManager.java:197)
> {code}
> The problem is that call of createEntityManagerFactories() in EntityManagerFactoryManager.bundleStateChange()
is made by BUNDLE.RESOLVED event.
> The lookup of data source is failed, because the bundle context is not yet available
(call by BUNDLE.RESOLVED event). The createEntityManagerFactory is called again by Bundle.ACTIVE
event, the problem is that emfs hash map is already created, but it is empty.
> Therefore  STARTED/ACTIVE createEntityManagerFactories() is called, but makes nothing.
> Attached patch contains two changes:
> a) log runtime exception throwing by providerService.createContainerEntityManagerFactory
> b) adds check to empty hash map:
> if(((emfs == null) || emfs.isEmpty()) && !quiesce)
> The patch fixes the problem.
> Basically it should analyzed is call createEntityManagerFactories() really necessary
for Bundle.RESOLVED event. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message