Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate "Session closed" error with two apps using hibernate

 
Scott Wilson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

Thanks for reading my post.

I am relatively new to hibernate and my application has been using it for about 12 months now, without much issue. The application is an ear file, within weblogic uses it to access data within the database and also the application contains JBPM, which also uses hibernate. The database is Oracle.

The "Session closed" issue has come about when the application was integrated into a larger environment. There is an API within this environment that also uses hibernate. When I try to use this API, I can do so successfully at first, but after a short time, I get the "session closed" error.

Both applications are using their own hibernate.cfg.xml files which are contained in their respective ear files.

My question is, does the hibernate session that is initially created by the other application need to be made available for my application to use? Is there a setting that will persist the hibernate instance or force two hibernate instances, so that each application will have their own hibernate? I do know for sure that my application works within an EJB. Is there some touchy issue that I have to be aware of when dealing with EJBs and hibernate?

Both applications work correctly when in the weblogic environment alone.

Any information would be helpful.

Thanks,

Scott Wilson
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well each application should create their own single instance of a SessionFactory, and get Sessions from that factory. So they should be completely seperate between apps. Can you paste the stack trace? I think the two applications is just a red herring to the real issue.

Are you trying to share connection pools between the two apps, and maybe you just can't create any more Connections in the pools. Although I still don't think that that is it.

Mark
 
Scott Wilson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the stack trace we get:

####<Mar 24, 2008 9:54:12 PM GMT+00:00> <Notice> <Stdout> <appl.red.gccs.smil.mil> <enclaveDefDom_cbrnClusManSvr1> <[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1206395652992> <000000> <Logging logDebug string : initiateCreateProject in PAIEJB!>
####<Mar 24, 2008 9:54:13 PM GMT+00:00> <Notice> <Stdout> <appl.red.gccs.smil.mil> <enclaveDefDom_cbrnClusManSvr1> <[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1206395653356> <000000> <Logging logError string :[Error getUserByOrganization in SAFE SAFEConfigHomeImpl::findByNodeString(String): values: [safe.dm.policy.Password]:javax.transaction.TransactionRolledbackException: EJB Exception: : javax.ejb.EJBException: nested exception is: safe.ri.persistence.DataException: org.hibernate.SessionException: Session is closed!
safe.ri.persistence.DataException: org.hibernate.SessionException: Session is closed!
at safe.ri.persistence.DataCoordinator.getConfigurationItemByNodeString(DataCoordinator.java:7258)
at safe.ri.dmsvc.DataManagerBean.getConfigurationItemByNodeString(DataManagerBean.java:3753)
at safe.ri.dmsvc.DataManagerEJB_mx9c55_EOImpl.getConfigurationItemByNodeString(DataManagerEJB_mx9c55_EOImpl.java:1597)
at safe.ri.dmsvc.DataManagerEJB_mx9c55_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:550)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:440)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:436)
at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:58)
at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:975)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: org.hibernate.SessionException: Session is closed!
at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
at org.hibernate.impl.SessionImpl.createCriteria(SessionImpl.java:1472)
at safe.ri.persistence.DataCoordinator.getConfigurationItemByNodeString(DataCoordinator.java:7246)
... 13 more
javax.ejb.EJBException: nested exception is: safe.ri.persistence.DataException: org.hibernate.SessionException: Session is closed!
at safe.ri.dmsvc.DataManagerBean.createEJBException(DataManagerBean.java:79)
at safe.ri.dmsvc.DataManagerBean.getConfigurationItemByNodeString(DataManagerBean.java:3756)
at safe.ri.dmsvc.DataManagerEJB_mx9c55_EOImpl.getConfigurationItemByNodeString(DataManagerEJB_mx9c55_EOImpl.java:1597)
at safe.ri.dmsvc.DataManagerEJB_mx9c55_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:550)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:440)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:436)
at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:58)
at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:975)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: safe.ri.persistence.DataException: org.hibernate.SessionException: Session is closed!
at safe.ri.persistence.DataCoordinator.getConfigurationItemByNodeString(DataCoordinator.java:7258)
at safe.ri.dmsvc.DataManagerBean.getConfigurationItemByNodeString(DataManagerBean.java:3753)
... 12 more

#############################################################

My app is printing:

<Logging logDebug string : initiateCreateProject in PAIEJB!>

The failure of the app I am calling, safe.* is generating the rest.

Thanks,

Scott Wilson
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so now briefly describe your architecture. How and where are your Sessions created? Are you injecting an EntityManager with EJB3? those kind of information.

Based on the stack trace, also post the code/method for the following

DataCoordinator.getConfigurationItemByNodeString(DataCoordinator.java:7246)
DataManagerBean.getConfigurationItemByNodeString(DataManagerBean.java:3756)

Thanks

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic