Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] EntityManager life-cycle..

The rest of the stack trace is below - I think that I have at least 2 or 3 queries happening "simultaneously" during the startup, and from what I can tell running in the debugger the error seems to happen after one of  the queries has called the em.close(), so it seems that somehow there is some shared state between EntityManager instances that is being cleared by the close()... but it is a little tricky to see exactly what is going on as I am new to netbeans RCP....

[EL Finer]: 2011-03-28 20:45:34.424--Thread(Thread[main,5,IDE Main])--JavaSECMPInitializer - transformer is null.
SEVERE [org.netbeans.core.modules]
Local Exception Stack: 
Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [uk.ac.man.jb.emerlin_dbaccess_nbm_1.0-SNAPSHOTPU] failed.
Internal Exception: java.lang.NullPointerException
        at org.eclipse.persistence.exceptions.EntityManagerSetupException.deployFailed(EntityManagerSetupException.java:218)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:367)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:242)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:230)
        at uk.ac.man.jb.emerlin.dbaccess.BaseJPAController.getEntityManager(BaseJPAController.java:28)
        at uk.ac.man.jb.emerlin.dbaccess.RackJpaController.findRackEntities(RackJpaController.java:107)
        at uk.ac.man.jb.emerlin.dbaccess.RackJpaController.findRackEntities(RackJpaController.java:99)
        at uk.ac.man.jb.emerlin.emcbegui.Installer.restored(Installer.java:32)
        at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:426)
        at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:366)
        at org.netbeans.ModuleManager.enable(ModuleManager.java:944)
        at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:318)
        at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:254)
        at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:286)
        at org.netbeans.core.startup.Main.getModuleSystem(Main.java:172)
        at org.netbeans.core.startup.Main.start(Main.java:302)
        at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:114)
        at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:340)
         ... 17 more
Caused: javax.persistence.PersistenceException
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:367)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:242)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:230)
        at uk.ac.man.jb.emerlin.dbaccess.BaseJPAController.getEntityManager(BaseJPAController.java:28)
        at uk.ac.man.jb.emerlin.dbaccess.RackJpaController.findRackEntities(RackJpaController.java:107)
        at uk.ac.man.jb.emerlin.dbaccess.RackJpaController.findRackEntities(RackJpaController.java:99)
        at uk.ac.man.jb.emerlin.emcbegui.Installer.restored(Installer.java:32)
        at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:426)
        at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:366)
        at org.netbeans.ModuleManager.enable(ModuleManager.java:944)
        at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:318)
        at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:254)
        at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:286)
        at org.netbeans.core.startup.Main.getModuleSystem(Main.java:172)
        at org.netbeans.core.startup.Main.start(Main.java:302)
        at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:114)
[catch] at java.lang.Thread.run(Thread.java:680)

On 2011-03 -28, at 18:15, Tom Ware wrote:

> Hi Paul,
> 
>  Can you please provide the rest of the stack trace?  (At least including the first line of code that does not belong to EclipseLink)
> 
> -Tom
> 
> Paul Harrison wrote:
>> Hi,
>> It seems that the recommended pattern is to have a relatively shortly lived EntityManager and use it with the following sort of code
>>        try {
>>            em = getEntityManager();
>>            em.getTransaction().begin();
>>            //.... do something....
>>            em.getTransaction().commit();
>>        } finally {
>>            if (em != null) {
>>                em.close();
>>            }
>>        }
>> where the getEntityManager() call uses a long lived EntityManagerFactory to get new EntityManager. I am having a problem with this pattern in a multi-threaded J2SE environment (specifically Netbeans RCP), where I am getting all sorts of strange exceptions - often  the following
>> Caused by: java.lang.NullPointerException
>>        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:340)
>>        ... 17 more
>> caused by the class field "processor" being null when two statements earlier it was obviously not null (if in the same thread)
>> This would tend to suggest that there are threading issues with the EntityManagerFactory/EntityManager that I am not aware of - does anyone have experience of any special tricks necessary to make Eclipselink work properly in Netbeans RCP? I am using Eclipselink 2.2.0 and Netbeans RCP 6.9.1.
>> Paul.
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Dr. Paul Harrison
JBCA, Manchester University
http://www.manchester.ac.uk/jodrellbank





Back to the top