Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] java.lang.NullPointerException at org.eclipse.persistence.internal.jpa.EntityManagerImpl.getActivePersistenceContext(EntityManagerImpl.java:855)

Hi
I am trying to get the reference to an active session but catching this
exeption:

[25.09.08 10:00:58:328 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.281--UnitOfWork(302912014)--Thread(Thread[WebContainer :
0,5,main])--TX beforeCompletion callback, status=STATUS_ACTIVE
[25.09.08 10:00:58:328 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.328--UnitOfWork(302912014)--Thread(Thread[WebContainer :
0,5,main])--begin unit of work commit
[25.09.08 10:00:58:562 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.562--UnitOfWork(1071136728)--Thread(Thread[WebContainer :
0,5,main])--TX beforeCompletion callback, status=STATUS_ACTIVE
[25.09.08 10:00:58:562 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.562--UnitOfWork(1071136728)--Thread(Thread[WebContainer :
0,5,main])--begin unit of work commit
[25.09.08 10:00:58:625 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.609--UnitOfWork(302912014)--Thread(Thread[WebContainer :
0,5,main])--TX afterCompletion callback, status=COMMITTED
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.656--UnitOfWork(302912014)--Thread(Thread[WebContainer :
0,5,main])--end unit of work commit
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.656--UnitOfWork(302912014)--Thread(Thread[WebContainer :
0,5,main])--release unit of work
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.656--ClientSession(1848012326)--Thread(Thread[WebContainer :
0,5,main])--client released
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.656--UnitOfWork(1071136728)--Thread(Thread[WebContainer :
0,5,main])--TX afterCompletion callback, status=COMMITTED
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.656--UnitOfWork(1071136728)--Thread(Thread[WebContainer :
0,5,main])--end unit of work commit
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.656--UnitOfWork(1071136728)--Thread(Thread[WebContainer :
0,5,main])--release unit of work
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O [EL Finer]: 2008.09.25
10:00:58.656--ClientSession(1010711614)--Thread(Thread[WebContainer :
0,5,main])--client released
[25.09.08 10:00:58:656 MSD] 00000052 SystemOut     O After the ut.commit()
[25.09.08 10:00:58:671 MSD] 00000052 ExceptionUtil E   CNTR0020E: В объекте
EJB возникла непредвиденная исключительная ситуация при вызове метода
"releaseOebsByTimeAndOrganizationId" объекта EJB
"BeanId(oebs#oebsEJB.jar#OebsInterfaceImpl,
980C8627-011C-4000-E000-05140A0008BD)". Сведения об исключительной ситуации:
java.lang.NullPointerException
	at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.getActivePersistenceContext(EntityManagerImpl.java:855)
	at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.getActiveSession(EntityManagerImpl.java:574)
	at
ejb3.OebsInterfaceImpl.releaseOebsByTimeAndOrganizationId(OebsInterfaceImpl.java:502)

My code is:

		@Resource javax.transaction.UserTransaction ut;
...
		ut.begin();

		jpaEM = org.eclipse.persistence.jpa.JpaHelper.getEntityManager(em);
		uow = jpaEM.getActiveSession().getActiveUnitOfWork();  //Here it works
well

...
		ut.commit();

		jpaEM = org.eclipse.persistence.jpa.JpaHelper.getEntityManager(em);

		if(jpaEM.getActiveSession().isDatabaseSession()){ //Here I catch the
exception
			((DatabaseSession)jpaEM.getActiveSession()).logout();
			System.out.println("After the
((DatabaseSession)jpaEM.getActiveSession()).logout()");	
		}
		else if(jpaEM.getActiveSession().isServerSession()){
			((ServerSession)jpaEM.getActiveSession()).logout();
			System.out.println("After the
((ServerSession)jpaEM.getActiveSession()).logout()");				
		}


I need this reference to logout from the database.
Does the exception mean that I can not get it after I commited the
transaction?
Can you give me the tip how to logout from the database after I commited the
transaction?


Regards,
Dmitry

-- 
View this message in context: http://www.nabble.com/java.lang.NullPointerException-at-org.eclipse.persistence.internal.jpa.EntityManagerImpl.getActivePersistenceContext%28EntityManagerImpl.java%3A855%29-tp19663740p19663740.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top