Foros del Web » Programación para mayores de 30 ;) » Java »

javax.persistence.PersistenceException: org.hibernate.SessionException: Session is cl

Estas en el tema de javax.persistence.PersistenceException: org.hibernate.SessionException: Session is cl en el foro de Java en Foros del Web. buenas tengo este error al debugear cuando llego a esta linea: Código: Cliente cli= (Cliente)entityManager.createNamedQuery("findCliente").setParameter("nCli", noCli).getSingleResult(); me salta este error entityManager esta injectado no me ...
  #1 (permalink)  
Antiguo 14/06/2011, 09:21
 
Fecha de Ingreso: febrero-2011
Mensajes: 10
Antigüedad: 10 años, 2 meses
Puntos: 0
javax.persistence.PersistenceException: org.hibernate.SessionException: Session is cl

buenas tengo este error al debugear cuando llego a esta linea:
Código:
Cliente cli= (Cliente)entityManager.createNamedQuery("findCliente").setParameter("nCli", noCli).getSingleResult();
me salta este error entityManager esta injectado no me da null, como anteriormente.
El error que me da es este:
Código:
40984 [http-8080-3] DEBUG com.jeveris.pl.navigation.executor.NavigationController  - Using spring-defined bean: service2F12 for action service: com.bankeveris.flujo1DemoBankeveris.Service2F12
40984 [http-8080-3] INFO  com.jeveris.pl.navigation.model.ActionService  - Before executing ActionService: com.bankeveris.flujo1DemoBankeveris.Service2F12|flowInstanceId: 35733233768402690|flowId: Flujo1DemoBankeveris|lastNodeId: BuscarCliente|requiredTransitionId: mandarDatos|nextNodeId: BuscarDatos|containerId: container_1
67953 [http-8080-3] DEBUG org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler  - Creating new EntityManager for shared EntityManager invocation
68203 [http-8080-3] DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils  - Closing JPA EntityManager
javax.persistence.PersistenceException: org.hibernate.SessionException: Session is closed!
	at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
	at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:107)
	at com.bankeveris.dao.ClienteDaoImpl.findCliente(ClienteDaoImpl.java:47)
	at com.bankeveris.service.ServiceClienteImpl.cliente(ServiceClienteImpl.java:29)
	at com.bankeveris.flujo1DemoBankeveris.Service2F12.execute(Service2F12.java:29)
	at com.jeveris.pl.navigation.model.ActionService.service(ActionService.java:41)
	at com.jeveris.pl.navigation.executor.NavigationController.processNavigation(NavigationController.java:149)
	at com.jeveris.pl.navigation.jsfintegration.PLNavigationHandler.handleNavigation(PLNavigationHandler.java:108)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
	at javax.faces.component.UICommand.broadcast(UICommand.java:387)
	at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
	at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
	at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
	at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:100)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
	at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
	at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.SessionException: Session is closed!
	at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:49)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1110)
	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
	at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:81)
	... 40 more
68219 [http-8080-3] ERROR com.jeveris.pl.navigation.executor.NavigationController  - Handle error for exception id=1308064536048: javax.persistence.PersistenceException: org.hibernate.SessionException: Session is closed!
68219 [http-8080-3] ERROR com.jeveris.pl.navigation.executor.NavigationController  - Flow information for exception id=1308064536048: flowInstanceId: 35733233768402690|flowId: Flujo1DemoBankeveris|lastNodeId: BuscarCliente|requiredTransitionId: mandarDatos|nextNodeId: BuscarDatos|containerId: container_1
68219 [http-8080-3] ERROR com.jeveris.pl.navigation.executor.NavigationController  - Go to error flow
68219 [http-8080-3] INFO  com.jeveris.pl.navigation.executor.NavigationHelper  - Access to node errorService in flow error for resource com.jeveris.pl.core.services.ErrorService is granted
68219 [http-8080-3] INFO  com.jeveris.pl.navigation.executor.NavigationHelper  - Flow started|flowInstanceId: 1630240432162023492|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId: errorService|containerId: container_1
68219 [http-8080-3] DEBUG com.jeveris.pl.navigation.executor.NavigationController  - Searching for spring-defined bean errorService
68219 [http-8080-3] WARN  com.jeveris.pl.businesslogic.control.BusinessLogicCaller  - Service (spring bean) with id errorService was not found. Returning null reference
68219 [http-8080-3] WARN  com.jeveris.pl.navigation.executor.NavigationController  - Spring-defined bean not found for action service: com.jeveris.pl.core.services.ErrorService. Instantiating brand-new action service...
68219 [http-8080-3] INFO  com.jeveris.pl.navigation.model.ActionService  - Before executing ActionService: com.jeveris.pl.core.services.ErrorService|flowInstanceId: 1630240432162023492|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId: errorService|containerId: container_1
68219 [http-8080-3] INFO  MONITOR  - PLResource: com.jeveris.pl.core.services.ErrorService; Time: 0; Active Flow Info: flowInstanceId: 1630240432162023492|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId: errorService|containerId: container_1
Haber si me podeis echar una manita pleases
  #2 (permalink)  
Antiguo 14/06/2011, 11:37
Avatar de FiruzzZ  
Fecha de Ingreso: diciembre-2007
Ubicación: en casa
Mensajes: 470
Antigüedad: 13 años, 4 meses
Puntos: 41
Respuesta: javax.persistence.PersistenceException: org.hibernate.SessionException: Se

En tu log está la respuesta..
68203 [http-8080-3] DEBUG org.springframework.orm.jpa.EntityManagerFactoryUt ils - Closing JPA EntityManager
javax.persistence.PersistenceException: org.hibernate.SessionException: Session is closed!

..como no mostrás mucho código mas que el intento de una JPQL.. podrías chequear que

entityManager.isOpen();
entityManager.getTransaction().isActive(); // <--- este creo que no es necesario ya que es solo una consulta, no hay un commit ligado a futuro a esta, por eso "creo"
__________________
BadProgrammerException!

Última edición por FiruzzZ; 14/06/2011 a las 11:43
  #3 (permalink)  
Antiguo 15/06/2011, 01:06
 
Fecha de Ingreso: febrero-2011
Mensajes: 10
Antigüedad: 10 años, 2 meses
Puntos: 0
Respuesta: javax.persistence.PersistenceException: org.hibernate.SessionException: Se

esta es mi clase
Código:
@Stateless
@Local(ClienteDao.class)
@Service
public class ClienteDaoImpl implements ClienteDao {

	//EntityManagerFactory factory = Persistence.createEntityManagerFactory("j-everis-2.0");
	
	/** Entity Manager */
	@PersistenceContext 
	private EntityManager entityManager;//= factory.createEntityManager();
	
	
	
	

	
	/** Logger utilizado por la clase. */
	//private static PLLogger logger = PLLogger.getLogger(ClienteDaoImpl.class);
	
		

		@SuppressWarnings("unchecked")
		public List<Cliente> findAllCliente() {
			System.out.println("Dao: Accediendo a BBDD....");
			return (List<Cliente>)entityManager.createNamedQuery("findAllCliente").getResultList();
		}


		public Cliente findCliente(int noCli) {
			Cliente cli= (Cliente)entityManager.createNamedQuery("findCliente").setParameter("nCli", noCli).getSingleResult();
			System.out.println("Cliente name: " + cli.getNombre());
			return cli;
		}

	
	
		
	

}
si uso esto:
entityManager.isOpen();

no hace nada y si uso esta:
entityManager.getTransaction().isActive();

me da este error
Código:
6047 [http-8080-2] INFO  com.jeveris.pl.navigation.model.ActionService  - Before executing ActionService: com.bankeveris.flujo1DemoBankeveris.Service2F12|flowInstanceId: 6473634710308805577|flowId: Flujo1DemoBankeveris|lastNodeId: BuscarCliente|requiredTransitionId: mandarDatos|nextNodeId: BuscarDatos|containerId: container_1
java.lang.IllegalStateException: Not allowed to create transaction on shared EntityManager - use Spring transactions or EJB CMT instead
	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:159)
	at $Proxy47.getTransaction(Unknown Source)
	at com.bankeveris.dao.ClienteDaoImpl.findCliente(ClienteDaoImpl.java:48)
	at com.bankeveris.service.ServiceClienteImpl.cliente(ServiceClienteImpl.java:29)
	at com.bankeveris.flujo1DemoBankeveris.Service2F12.execute(Service2F12.java:29)
	at com.jeveris.pl.navigation.model.ActionService.service(ActionService.java:41)
	at com.jeveris.pl.navigation.executor.NavigationController.processNavigation(NavigationController.java:149)
	at com.jeveris.pl.navigation.jsfintegration.PLNavigationHandler.handleNavigation(PLNavigationHandler.java:108)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
	at javax.faces.component.UICommand.broadcast(UICommand.java:387)
	at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
	at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
	at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
	at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:100)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
	at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
	at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:595)
46047 [http-8080-2] ERROR com.jeveris.pl.navigation.executor.NavigationController  - Handle error for exception id=1308123943990: java.lang.IllegalStateException: Not allowed to create transaction on shared EntityManager - use Spring transactions or EJB CMT instead
46047 [http-8080-2] ERROR com.jeveris.pl.navigation.executor.NavigationController  - Flow information for exception id=1308123943990: flowInstanceId: 6473634710308805577|flowId: Flujo1DemoBankeveris|lastNodeId: BuscarCliente|requiredTransitionId: mandarDatos|nextNodeId: BuscarDatos|containerId: container_1
46047 [http-8080-2] ERROR com.jeveris.pl.navigation.executor.NavigationController  - Go to error flow
46047 [http-8080-2] INFO  com.jeveris.pl.navigation.executor.NavigationHelper  - Access to node errorService in flow error for resource com.jeveris.pl.core.services.ErrorService is granted
46047 [http-8080-2] INFO  com.jeveris.pl.navigation.executor.NavigationHelper  - Flow started|flowInstanceId: 1276950184573420647|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId: errorService|containerId: container_1
46047 [http-8080-2] DEBUG com.jeveris.pl.navigation.executor.NavigationController  - Searching for spring-defined bean errorService
46047 [http-8080-2] WARN  com.jeveris.pl.businesslogic.control.BusinessLogicCaller  - Service (spring bean) with id errorService was not found. Returning null reference
46047 [http-8080-2] WARN  com.jeveris.pl.navigation.executor.NavigationController  - Spring-defined bean not found for action service: com.jeveris.pl.core.services.ErrorService. Instantiating brand-new action service...
46047 [http-8080-2] INFO  com.jeveris.pl.navigation.model.ActionService  - Before executing ActionService: com.jeveris.pl.core.services.ErrorService|flowInstanceId: 1276950184573420647|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId: errorService|containerId: container_1
46047 [http-8080-2] INFO  MONITOR  - PLResource: com.jeveris.pl.core.services.ErrorService; Time: 0; Active Flow Info: flowInstanceId: 1276950184573420647|flowId: error|lastNodeId: null|requiredTransitionId: init|nextNodeId: errorService|containerId: container_1

Última edición por esgoru; 15/06/2011 a las 01:48
  #4 (permalink)  
Antiguo 15/06/2011, 08:28
 
Fecha de Ingreso: febrero-2011
Mensajes: 10
Antigüedad: 10 años, 2 meses
Puntos: 0
Respuesta: javax.persistence.PersistenceException: org.hibernate.SessionException: Se

Ya lo he conseguido tenia que adjuntar los paquetes en un archivo de configuracion, para que los daos pudieran ser usados

Etiquetas: session
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:53.