openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rudolph, Dirk" <>
Subject AW: ClassNotFoundExceptions for Entity classes after bundle redeployment
Date Sat, 28 Sep 2013 06:19:24 GMT
Hi Kevin,

we are using OpenJPA 2.2.2 with container-managed persistence with Apache Aries JPA container
(1.1.0) and when the persistence bundle is redeployed the container deregisters the EMFs as
expected (I think). The enhancement is done on build time and PCRegistry.register is called
for each entity in static initializer as expected.

I think the problem is that Felix instantiates a new ClassLoader when a bundle is redoplyed.
All classes loaded with the new ClassLoader are not equal to the classes loaded with the old
ClassLoader. These new classes get initialized and the static initializer puts them in the
PCRegistry without removing instances of the previous ClassLoader. I checked our codebase
whether any instance holds references to instances of our entities but couldn't find any.
I'm not sure why the classes in PCRegistry don't get collected by the garbage collector when
the bundle is stopped before update. Am I responsible for closing EM during deactivation of
my persistence service or is this also done by the container when EMF is deregistered?

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

    <persistence-unit name="myUserBundlePU" transaction-type="JTA">
        <description>Persistence Unit for user service. Uses container managed transactions.</description>


        <!-- Entity classes -->

            <property name="openjpa.Log" value="DefaultLevel=INFO, Runtime=INFO, SQL=INFO,
Tool=INFO" />

Thanks so far,

-----Ursprüngliche Nachricht-----
Von: Kevin Sutter [] 
Gesendet: Donnerstag, 26. September 2013 14:57
Betreff: Re: ClassNotFoundExceptions for Entity classes after bundle redeployment

Hi Dirk,
Are you using container-managed persistence or application-managed persistence?  That is,
who is controlling the lifecycle of your EMFs and EMs?  If the PCRegistry is continuing to
grow and grow and grow, this sounds like an EMF or EM leak where they are not getting properly

What version of OpenJPA is in use?  In 2.2.0, OpenJPA put a feature in place [1] that helps
with resolving memory issues when failing to close EMFs.

Another thing to look at is how you are enhancing your Entities for OpenJPA monitoring.  Are
you doing build-time enhancement or some type of runtime enhancement?  Posting your persistence.xml
would also be good.

-- Kevin


On Thu, Sep 26, 2013 at 3:52 AM, Rudolph, Dirk

> Hi all,
> we are using OpenJPA in our osgi environment (Apache Felix) and got 
> some (non-deterministic ) ClassNotFoundExceptions caused by already closed jars.
> This occurs only when the persistence bundle we are using is redeployed.
> We mentioned that the PCRegistry.register method is invoked when our 
> Entity-classes get instantiated. This works as expected. The meta data 
> map of the Registry is filled and successfully passed through the 
> MetadataRepository. After a redeployment this happens again and again 
> so the map of registered metas in the PCRegistry grows and grows and 
> contains classes referencing already disposed classloaders. When the 
> registered metadata get used this can cause ClassNotFoundExceptions 
> when an outdated classloader is access. I assume that this happens 
> non-deterministic because the order of the data to iterate over isn't 
> predictable. Is this diagnostic right?
> Should PCRegistry.deRegister be called when a bundle is stopped before 
> update? Can this be done by any configuration?
> Thank's so far,
> Dirk Rudolph
> T-Systems Multimedia Solutions GmbH
> Organisationseinheit CCS
> Dirk Rudolph
> Software-Entwicklung, OCJP
> Hausanschrift: Riesaer Straße 5, 01129 Dresden
> Postanschrift: Postfach 10 02 24, 01072 Dresden
> +49 351 2820-5363       (Tel)
> E-Mail: 
> <
> >
> Internet: <>
> T-Systems Multimedia Solutions GmbH
> Aufsichtsrat: Klaus Werner (Vorsitzender)
> Geschäftsführung: Peter Klingenburg, Dr. Jens Nebendahl
> Handelsregister: Amtsgericht Dresden HRB 11433 Sitz der Gesellschaft: 
> Dresden
> Ust-IdNr.: DE 811 807 949

View raw message