Hi friends, i REALLY need help with this one or my boss is gonna cut my head off in 5 hours.
I MUST SOLVE THIS SO PLEASE HELP ME!!
the error message i get is this one:
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of ar.com.bgba.ecompany.wfsi.Ayuda.?
that produces after i Save an object of the class Recurso (in english is "resource")
The funny thing and very annoying is that i tested it the las friday to see if this worked properly and i found it working well.
But today one of the bosses of the users group came and we started making a test suit (not automated but manually) and this thing didn't work, so figure out how i am. Angry.
Next, i present you the relevant documents so you can help me:
Hibernate version:
2.1
Mapping documents:
Class Recurso: Recurso.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- ar.com.bgba.ecompany.wfsi.Recurso root -->
<class name="ar.com.bgba.ecompany.wfsi.Recurso" table="Recurso">
<id name="uid" type="long" column="uid" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="nombre" column="nombre" type="string"/>
<property name="descripcion" column="descripcion" type="string"/>
<property name="disponible" column="disponible" type="boolean"/>
<!--
<many-to-one name="ambito" column="ambito" unique="false" class="ar.com.bgba.ecompany.wfsi.Ambito"/>
-->
<set name="ambitos" table="ambito_recurso" lazy="false" cascade="save-update">
<key column="recurso_uid"/>
<many-to-many class="ar.com.bgba.ecompany.wfsi.Ambito" column="ambito_uid"/>
</set>
<!-- <set name="opciones" table="opciones_del_recurso" lazy="false" cascade="save-update"> -->
<set name="opciones" table="opciones_del_recurso" inverse="true" lazy="false" cascade="none">
<key column="uid_recurso"/>
<one-to-many class="ar.com.bgba.ecompany.wfsi.Opcion"/>
</set>
<!--many-to-one name="autor" class="ar.com.bgba.ecompany.wfsi.Usuario" column="autor"/-->
<component name="autor"
class="ar.com.bgba.ecompany.wfsi.Usuario">
<property name="legajo" column="autor"
type="string"/>
</component>
<component name="modificadoPor"
class="ar.com.bgba.ecompany.wfsi.Usuario">
<property name="legajo" column="modificado_por"
type="string"/>
</component>
<property name="fechaAlta" column="fechaAlta" type="timestamp"/>
<property name="fechaUltimaModificacion" column="fechaUltimaModificacion" type="timestamp"/>
<many-to-one name="ayudaSoporte" column="ayuda_soporte" class="ar.com.bgba.ecompany.wfsi.Ayuda" cascade="none" unique="true" />
<many-to-one name="ayudaAprobador" column="ayuda_aprobador" class="ar.com.bgba.ecompany.wfsi.Ayuda" cascade="none" unique="true" />
<many-to-one name="ayudaUsuario" column="ayuda_usuario" class="ar.com.bgba.ecompany.wfsi.Ayuda" cascade="none" unique="true" />
<set name="owners_" table="owners" lazy="false">
<key column="uid_recurso"/>
<!--composite-element class="ar.com.bgba.ecompany.wfsi.Usuario">
<property name="legajo" column="usuario" type="string" not-null="true"/>
</composite-element-->
<element column="usuario" type="string" not-null="true"/>
<!--many-to-many class="ar.com.bgba.ecompany.wfsi.Usuario"/-->
</set>
<!--many-to-one name="responsable" column="usuario_responsable_id" cascade="all" class="ar.com.bgba.ecompany.wfsi.Usuario"/-->
<!--component name="responsable" class="ar.com.bgba.ecompany.wfsi.Usuario">
<property name="legajo" column="responsable" type="string"/>
</component-->
<set name="grupos" table="relacion_grupos_recursos" lazy="false" cascade="save-update">
<key column="recurso_id"/>
<many-to-many class="ar.com.bgba.ecompany.wfsi.Grupo" column="grupo_id"/>
</set>
<property name="nivelAprobadoresUsuarioPropioDesde" column="nivelAprobadoresUsuarioPropioDesde" type="int"/>
<property name="nivelAprobadoresUsuarioPropioHasta" column="nivelAprobadoresUsuarioPropioHasta" type="int"/>
<set name="gruposPropioUsuario" table="asociacion_recurso_grupo_propio_usuario"
lazy="false"
cascade="all-delete-orphan">
<key column="recurso_uid"/>
<one-to-many class="ar.com.bgba.ecompany.wfsi.RecursoGrupoGDPropioUsuario"/>
</set>
<property name="nivelAprobadoresOtrosUsuariosDesde" column="nivelAprobadoresOtrosUsuariosDesde" type="int"/>
<property name="nivelAprobadoresOtrosUsuariosHasta" column="nivelAprobadoresOtrosUsuariosHasta" type="int"/>
<set name="gruposOtrosUsuarios" table="asociacion_recurso_grupo_otros_usuarios"
lazy="false"
cascade="all-delete-orphan">
<key column="recurso_uid"/>
<one-to-many class="ar.com.bgba.ecompany.wfsi.RecursoGrupoGDOtrosUsuarios"/>
</set>
<!--
<property name="nivelAprobadoresUsuariosNuevosDesde" column="nivelAprobadoresUsuariosNuevosDesde" type="int"/>
<property name="nivelAprobadoresUsuariosNuevosHasta" column="nivelAprobadoresUsuariosNuevosHasta" type="int"/>
-->
<property name="grupoResponsable" column="grupo_responsable" type="string"/>
</class>
</hibernate-mapping>
Class Ayuda: Ayuda.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<!-- ar.com.bgba.ecompany.wfsi.Alcance root -->
<class name="ar.com.bgba.ecompany.wfsi.Ayuda" table="Ayuda">
<id name="uid" type="long" column="uid" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="descripcion" column="descripcion" type="string"/>
<property name="tipoAyuda" column="tipoAyuda" type="int" />
<!--many-to-one name="autor" column="autor" class="ar.com.bgba.ecompany.wfsi.Usuario" unique="false" /-->
<component name="autor"
class="ar.com.bgba.ecompany.wfsi.Usuario">
<property name="legajo" column="autor"
type="string"/>
</component>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
/*
* Created on 30-mar-2004
*
* $Id$
*/
package ar.com.bgba.ecompany.wfsi.admin.action;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import ar.com.bgba.ecompany.commons.HibernateUtil;
import ar.com.bgba.ecompany.commons.struts.StrutsUtils;
import ar.com.bgba.ecompany.commons.struts.TransactionAction;
import ar.com.bgba.ecompany.wfsi.Ambito;
import ar.com.bgba.ecompany.wfsi.AmbitoGrupoGD;
import ar.com.bgba.ecompany.wfsi.Grupo;
import ar.com.bgba.ecompany.wfsi.Opcion;
import ar.com.bgba.ecompany.wfsi.Recurso;
import ar.com.bgba.ecompany.wfsi.RecursoGrupoGDOtrosUsuarios;
import ar.com.bgba.ecompany.wfsi.RecursoGrupoGDPropioUsuario;
import ar.com.bgba.ecompany.wfsi.Usuario;
import ar.com.bgba.ecompany.wfsi.admin.forms.RecursoForm;
import ar.com.bgba.ecompany.wfsi.dao.GrupoDAO;
import ar.com.bgba.ecompany.wfsi.helper.SessionHelper;
import ar.com.bgba.ecompany.wfsi.manager.UsuarioManager;
import ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants;
import ar.com.bgba.ecompany.wfsi.usuario.view.vo.UsuarioVO;
/**
* @author l0740098
*
* Guarda un recurso en la BD
*/
public class GuardarRecursoAction extends TransactionAction {
/**
* @param sessionName
*/
public GuardarRecursoAction() {
super("SESSION-RECURSO");
}
/*
* ****************************************************
* Attributes
* *****************************************************
*/
private static final Logger logger = Logger.getLogger(GuardarRecursoAction.class);
/*
* ****************************************************
* Private Methods
* *****************************************************
*/
/**
* @param strings
* @param session
* @return
*/
private Set getGrupos(String[] strings, Session session) {
// Importante! Eliminar los UIDs o traerá 2 instancias de grupos de UID iguales pero con otro hashcode!
LinkedList listaGrupos = new LinkedList();
CollectionUtils.addAll(listaGrupos, strings);
Set gruposSinRepeticion = new HashSet();
gruposSinRepeticion.addAll(listaGrupos);
Set grupos = new HashSet();
for (Iterator iter = gruposSinRepeticion.iterator(); iter.hasNext();) {
String grupoString = (String) iter.next();
try {
Grupo grupo = GrupoDAO.getInstance().loadGrupo(new Long(grupoString), session);
grupos.add(grupo);
} catch (NumberFormatException e) {
// Do nothing
} catch (HibernateException e) {
logger.debug("Error cargando grupos: ", e);
break;
}
}
return grupos;
}
/*
* ****************************************************
* Public Methods
* *****************************************************
*/
/* (non-Javadoc)
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse arg3,
Session session) throws Exception {
RecursoForm recursoForm = (RecursoForm) form;
Recurso recurso = recursoForm.getRecurso();
Set grupos = this.getGrupos(recursoForm.getGrupos(), session);
//System.out.println("[GuardarRecursoAction][execute] recuso Desde: " + recurso.getNivelAprobadoresUsuarioPropioDesde() + "Hasta: " + recurso.getNivelAprobadoresUsuarioPropioHasta());
// Obtengo el alcance que corresponda con id_alcance
//y lo seteo a recurso.
logger.debug("Recurso a guardar: " + recurso);
if (recurso.getUid() == 0)
{
recurso.setFechaAlta(new Date());
recurso.setDisponible(true);
}
recurso.setFechaUltimaModificacion(new Date());
recurso.setGrupos(grupos);
// Guardar los owners
Collection coleccionOwnerVOs = (Collection) request.getSession().getAttribute(Constants.KEY_OWNERS);
Collection owners = UsuarioManager.INSTANCE.buildDomainObjects(coleccionOwnerVOs);
recurso.getOwners().clear();
recurso.addAllToOwners(owners);
// Guardar el Responsable
logger.debug("Storing person in charge");
Collection coleccionResponsablesVOs = (Collection) request.getSession().getAttribute(Constants.KEY_RESPONSABLES);
if(coleccionResponsablesVOs != null)
{
if(coleccionResponsablesVOs.size() > 0)
{
Usuario responsable = UsuarioManager.INSTANCE.buildDomainObject((UsuarioVO)coleccionResponsablesVOs.iterator().next());
logger.debug("User in charge: [" + responsable.getLegajo() + "], " + responsable.getNombreCompleto());
recurso.setResponsable(responsable);
}
}
//Save the author only if i´m creating a resource. Otherwise, update the field ModifiedBy
if(recurso.getUid() == 0)
{
logger.debug("Saving Author.");
recurso.setAutor(SessionHelper.getInstance().getUsuario(request.getSession()));
logger.debug("Author saved.");
}
else
{
//I´m modifying, then i´ll update the field modificadoPor
logger.debug("Saving Modified by");
recurso.setModificadoPor(SessionHelper.getInstance().getUsuario(request.getSession()));
logger.debug("Modified by saved.");
}
//Save groups that belong to the responsables of the OWN user
java.util.Iterator iterTemp = null;
logger.debug("Getting own user´s groups from session.");
Collection gruposDeResponsable = (Collection)request.getSession().getAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_GRUPOS_PROPIO_USUARIO);
logger.debug("Groups retrieved: " + gruposDeResponsable);
if(gruposDeResponsable != null)
{
iterTemp = gruposDeResponsable.iterator();
while(iterTemp.hasNext())
{
AmbitoGrupoGD group = (AmbitoGrupoGD)iterTemp.next();
RecursoGrupoGDPropioUsuario groupToAdd = new RecursoGrupoGDPropioUsuario();
groupToAdd.setGrupo(group.getGrupo());
logger.debug("Group to add: " + groupToAdd);
//Let´s check if the group is not already in the set (this applies when we are modifying)
Iterator iter = recurso.getGruposPropioUsuario().iterator();
boolean addIt = true;
while(iter.hasNext() && addIt)
{
if(groupToAdd.getGrupo().equals( ((RecursoGrupoGDPropioUsuario)iter.next()).getGrupo() ))
{
addIt = false;
}
}
if(addIt)
{
logger.debug("Adding");
recurso.addToGruposPropioUsuario(groupToAdd);
}
}
}
//Save groups that belong to the responsables of the OTHER users
logger.debug("Getting other users´ groups from session.");
gruposDeResponsable = (Collection)request.getSession().getAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_GRUPOS_OTROS_USUARIOS);
logger.debug("Groups retrieved: " + gruposDeResponsable);
if(gruposDeResponsable != null)
{
iterTemp = gruposDeResponsable.iterator();
while(iterTemp.hasNext())
{
AmbitoGrupoGD group = (AmbitoGrupoGD)iterTemp.next();
RecursoGrupoGDOtrosUsuarios groupToAdd = new RecursoGrupoGDOtrosUsuarios();
groupToAdd.setGrupo(group.getGrupo());
logger.debug("Group to add: " + groupToAdd);
//Let´s check if the group is not already in the set (this applies when we are modifying)
Iterator iter = recurso.getGruposOtrosUsuarios().iterator();
boolean addIt = true;
while(iter.hasNext() && addIt)
{
if(groupToAdd.getGrupo().equals( ((RecursoGrupoGDOtrosUsuarios)iter.next()).getGrupo() ))
{
addIt = false;
}
}
if(addIt)
{
logger.debug("Adding");
recurso.addToGruposOtrosUsuarios(groupToAdd);
}
}
}
//SAVE the only responsable of the resource (it´s a groupGD)
gruposDeResponsable = (Collection)request.getSession().getAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_GRUPOS_RESPONSABLE);
if(gruposDeResponsable != null)
{
iterTemp = gruposDeResponsable.iterator();
while(iterTemp.hasNext())
{
AmbitoGrupoGD group = (AmbitoGrupoGD)iterTemp.next();
recurso.setGrupoResponsable(group.getGrupo());
}
}
if (recursoForm.getDisponible() != null)
{
recurso.setDisponible(true);
}
logger.debug("Before saving");
//Quitar los ambitos correspondientes a las opciones
//borrarAmbitosDeOpciones( recurso );
//evictOpciones(session, recurso);
guardarOpciones(session, recurso);
guardarAyudas(session, recurso);
session.saveOrUpdateCopy(recurso);
session.flush();
this.confirmarSession(request);
// Session ses2 = HibernateUtil.openSession();
//guardarGruposUsuarios(recurso, ses2);
// ses2.saveOrUpdate(recurso);
// ses2.flush();
// ses2.close();
logger.debug("After saving");
/* Session ses3 = HibernateUtil.openSession();
ses3.saveOrUpdate(recurso.getGruposPropioUsuario());
ses3.saveOrUpdate(recurso.getGruposOtrosUsuarios());
ses3.flush();
ses3.close();*/
logger.debug("Removing groups from the session");
request.getSession().removeAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_GRUPOS_PROPIO_USUARIO);
request.getSession().removeAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_GRUPOS_OTROS_USUARIOS);
request.getSession().removeAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_OWNERS);
request.getSession().removeAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_RESPONSABLES);
request.getSession().removeAttribute(ar.com.bgba.ecompany.wfsi.usuario.view.form.Constants.KEY_GRUPOS_RESPONSABLE);
return StrutsUtils.getInstance().addParameter(mapping.findForward("ok"),
"uid", String.valueOf(recurso.getUid()));
}
/**
* @param recurso
*/
private void borrarAmbitosDeOpciones(Recurso recurso) {
Set opcionesDeRecurso = recurso.getOpciones();
Set ambitosDeRecurso = recurso.getAmbitos();
Iterator itOpcionesDeRecurso = opcionesDeRecurso.iterator();
while( itOpcionesDeRecurso.hasNext())
{
Opcion opcion = (Opcion) itOpcionesDeRecurso.next();
Set ambitosDeOpcion = opcion.getAmbitos();
Iterator itAmbitosDeOpcion = ambitosDeOpcion.iterator();
while( itAmbitosDeOpcion.hasNext())
{
Ambito ambitoDeOpcion = (Ambito) itAmbitosDeOpcion.next();
Iterator itAmbitosDeRecurso = ambitosDeRecurso.iterator();
boolean ambitoDeOpcionDebeSerBorrado = true;
while( itAmbitosDeRecurso.hasNext())
{
Ambito ambitoDeRecurso = (Ambito)itAmbitosDeRecurso.next();
if( ambitoDeRecurso.getUid() == ambitoDeOpcion.getUid())
{
ambitoDeOpcionDebeSerBorrado = false;
break;
}
}
if( ambitoDeOpcionDebeSerBorrado)
{
ambitosDeOpcion.remove(ambitoDeOpcion);
}
}
}
}
/**
* @param session
* @param recurso
* @throws HibernateException
*/
private void guardarOpciones(Session session, Recurso recurso) throws HibernateException {
Set opciones = recurso.getOpciones();
Iterator it = opciones.iterator();
while( it.hasNext())
{
session.saveOrUpdateCopy(it.next());
}
}
/**
* @param session
* @param recurso
* @throws HibernateException
*/
private void guardarAyudas(Session session, Recurso recurso) throws HibernateException {
session.saveOrUpdateCopy(recurso.getAyudaAprobador());
session.saveOrUpdateCopy(recurso.getAyudaSoporte());
session.saveOrUpdateCopy(recurso.getAyudaUsuario());
}
/**
* @param session
* @param recurso
* @throws HibernateException
*/
private void evictOpciones(Session session, Recurso recurso) throws HibernateException {
Set opciones = recurso.getOpciones();
Iterator it = opciones.iterator();
while(it.hasNext())
{
/* Object obj = it.next();
if(session.contains(obj))
{
session.evict(obj);
}*/
session.evict(it.next());
}
}
/**
* @param recurso
* @param ses2
* @throws HibernateException
*/
private void guardarGruposUsuarios(Recurso recurso, Session ses2) throws HibernateException {
Iterator it = recurso.getGruposOtrosUsuarios().iterator();
while( it.hasNext())
{
ses2.saveOrUpdate(it.next());
}
it = recurso.getGruposPropioUsuario().iterator();
while( it.hasNext())
{
ses2.saveOrUpdate(it.next());
}
}
}
-------------------------------------------------------------------------
/*
* Created on 31-may-2004 : l0740098
*
*
*/
package ar.com.bgba.ecompany.commons.struts;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import ar.com.bgba.ecompany.commons.HibernateUtil;
/**
* @author l0740098 31-may-2004 12:10:14
*
* TransactionAction
*/
public abstract class TransactionAction extends AbstractTransactionAction
{
/**
* Logger for this class
*/
private static final Log logger = LogFactory
.getLog(TransactionAction.class);
/*
* **************************************************** Public Methods *****************************************************
*/
/**
* Nombre del forward que se ejecuta si la session expiro
*/
public static final String SESSION_EXPIRED = "expired";
//private static final Logger logger = Logger.getLogger(TransactionAction.class);
/*
* **************************************************** Constructor *****************************************************
*/
/**
* Default constructor
*
* @param sessionName
* un string que identifica a esta transaccion en particular en el contexto
*/
public TransactionAction(String sessionName)
{
super(sessionName);
}
/*
* **************************************************** Protected Methods *****************************************************
*/
/*
* **************************************************** Public Methods *****************************************************
*/
/*
* (non-Javadoc)
*
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
String hibernateSessionName = getHibernateSessionName();
///Session session = HibernateUtil.currentSession(request, hibernateSessionName);
logger.debug("TransactionAction.execute: antes de Session session = HibernateUtil.getSession();");
Session session = HibernateUtil.getSession();
logger.debug("TransactionAction.execute: despues de Session session = HibernateUtil.getSession();");
setSession(session);
/*
* if(session == null)
{
logger.debug("if session==null");
logger.debug("No existe una session previa con el ID: " + hibernateSessionName);
//return mapping.findForward(SESSION_EXPIRED);
session = HibernateUtil.currentSession();//TODO agregado ahora
} *
*/
if(!session.isConnected())
{
session.reconnect();
}
///Transaction transaction = HibernateUtil.currentTransaction(request, hibernateSessionName);
logger.debug("TransactionAction.execute: antes de HibernateUtil.beginTransaction();");
HibernateUtil.beginTransaction();
logger.debug("TransactionAction.execute: despues de HibernateUtil.beginTransaction();");
///logger.debug("Despues de Transaction transaction = HibernateUtil.currentTransaction(request, hibernateSessionName);");
///setTransaction(transaction);
///logger.debug("despues de setTransaction(transaction);");
if(session==null)
{
logger.debug("session es null");
}
else
{
logger.debug("session está conectada? -->" + session.isConnected());
logger.debug("session está abierta? -->" + session.isOpen());
}
/*
*
*if(getTransaction() == null)
{
logger.debug("entró por if getTransaction()==null");
logger.debug("No existe una transaccion previa con el ID: " + hibernateSessionName);
//return mapping.findForward(SESSION_EXPIRED);
Object obj = mapping.findForward(SESSION_EXPIRED);
if( obj == null )
{
logger.debug("mapping.findForward(SESSION_EXPIRED) es null\nVoy a abrir una transaction!!!");
transaction = session.beginTransaction();
setTransaction(transaction);//TODO aca agregue begintransaction!!!
}
else
{
logger.debug("mapping.findForward(SESSION_EXPIRED):" + obj.toString());
return (ActionForward)obj;
}
}*
*/
try
{
logger.debug("I´m going to the EXECUTE OF THE CHILD CLASS");
ActionForward actionForward = execute(mapping, form, request, response, session);
logger.debug("I came back from the EXECUTE OF THE CHILD CLASS");
logger.debug("actionForward returned from the EXECUTE OF THE CHILD CLASS: " + actionForward.toString());
if(session.isConnected() && session.isOpen())
{
// El usuario NO hizo commit => desconectar
///logger.debug("antes del transaction.commit();");
///transaction.commit();
logger.debug("TransactionAction.execute: antes de HibernateUtil.commitTransaction();");
HibernateUtil.commitTransaction();
logger.debug("TransactionAction.execute: despues de HibernateUtil.commitTransaction();");
///logger.debug("despues del transaction.commit();");
///session.disconnect();
logger.debug("TransactionAction.execute: antes de HibernateUtil.closeSession();");
HibernateUtil.closeSession();
logger.debug("TransactionAction.execute: despues de HibernateUtil.closeSession();");
}
logger.debug("session está conectada? " + session.isConnected());
logger.debug("session está abierta? " + session.isOpen());
logger.debug("ESTADO de la transaction");
logger.debug("transaction " + this.getTransaction());
return actionForward;
}
catch(HibernateException e)
{
request.removeAttribute(hibernateSessionName);
logger.error(e.getMessage(), e);
///if(transaction != null) transaction.rollback();
///logger.debug("luego de if(transaction != null) transaction.rollback();");
if(session != null) session.close();
throw e;
}
}
}
-------------------------------------------------------------
/*
* Created on 02-jun-2004 : l0740098
*
*
*/
package ar.com.bgba.ecompany.commons.struts;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import ar.com.bgba.ecompany.commons.HibernateUtil;
/**
* @author l0740098 02-jun-2004 11:48:33
*
* AbstractTransactionAction
*/
public abstract class AbstractTransactionAction extends Action {
/*
* ****************************************************
* Atributos
* *****************************************************
*/
private Session session = null;
private Transaction transaction = null;
private String hibernateSessionName;
private static final Logger logger = Logger.getLogger(AbstractTransactionAction.class);
/*
* ****************************************************
* Constructor
* *****************************************************
*/
/**
* Default constructor
*
* @param sessionName
* un string que identifica a esta transaccion en particular en
* el contexto
*/
public AbstractTransactionAction(String sessionName) {
if (sessionName == null) {
this.hibernateSessionName = "HIBERNATE-SESSION";
} else {
this.hibernateSessionName = sessionName;
}
}
/*
* ****************************************************
* Protected Methods
* *****************************************************
*/
/**
* Hace un rollback de la transaccion cierra la session de
* hibernate y la quita del contexto
*
* @param request HttpServletRequest
*/
protected void cancelarSession(HttpServletRequest request) {
try {
if (this.transaction != null) this.transaction.rollback();
} catch (HibernateException e1) {
logger.error(e1.getMessage(), e1);
}
this.session = HibernateUtil.currentSession(request, this.hibernateSessionName);
if (this.session != null) {
try {
this.session.close();
} catch (HibernateException e) {
logger.error(e.getMessage(), e);
}
}
request.getSession().removeAttribute(this.hibernateSessionName);
}
/**
* Hace un commit de la transaccion y deja abierta una nueva
*
*@throws HibernateException
*/
protected void commit() throws HibernateException {
if (this.transaction != null) this.transaction.commit();
this.transaction = this.session.beginTransaction();
}
/**
* Hace un commit de la transaccion, cierra la session
* de hibernate y la quita del contexto
*
* @param request HttpServletRequest
*/
protected void confirmarSession(HttpServletRequest request) {
///try {
/*
*
* if (this.transaction != null)
{
logger.debug("I´m gonna commit the transaction: [" + this.transaction + "]");
this.transaction.commit();
}
else
{
logger.debug("I do not comit the transaction cause transaction == null");
}*
*/
logger.debug("AbstractTransactionAction.comfirmarSession: antes de HibernateUtil.commitTransaction();");
HibernateUtil.commitTransaction();
logger.debug("AbstractTransactionAction.comfirmarSession: despues de HibernateUtil.commitTransaction();");
///} catch (HibernateException e1) {
/// logger.error(e1.getMessage(), e1);
///}
///this.session = HibernateUtil.currentSession(request, this.hibernateSessionName);
logger.debug("AbstractTransactionAction.comfirmarSession: antes de HibernateUtil.getSession();");
this.session = HibernateUtil.getSession();
logger.debug("AbstractTransactionAction.comfirmarSession: despues de HibernateUtil.getSession();");
if (this.session != null) {
///try {
///this.session.flush();
logger.debug("AbstractTransactionAction.comfirmarSession: antes de HibernateUtil.closeSession();");
HibernateUtil.closeSession();
logger.debug("AbstractTransactionAction.comfirmarSession: despues de HibernateUtil.closeSession();");
///this.session.close();
logger.debug("Hibernate Session flushed and closed AND disconnected!!!");
///} catch (HibernateException e) {
/// logger.error(e.getMessage(), e);
///}
}
request.getSession().removeAttribute(this.hibernateSessionName);
}
/**
* El metodo que ejecuta
* @param form
* @param mapping
* @param request
* @param response
* @param session
* @return
* @throws Exception
*/
protected abstract ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response, Session session) throws Exception;
/**
* @return Returns the hibernateSessionName.
*/
protected String getHibernateSessionName() {
return this.hibernateSessionName;
}
/**
* @return Returns the session.
*/
protected Session getSession() {
return this.session;
}
/**
* @return Returns the transaction.
*/
protected Transaction getTransaction() {
return this.transaction;
}
/**
* @param hibernateSessionName The hibernateSessionName to set.
*/
protected void setHibernateSessionName(String hibernateSessionName) {
this.hibernateSessionName = hibernateSessionName;
}
/**
* @param session The session to set.
*/
protected void setSession(Session session) {
this.session = session;
}
/**
* @param transaction The transaction to set.
*/
protected void setTransaction(Transaction transaction) {
this.transaction = transaction;
}
}
Full stack trace of any exception that occurs:
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:138) - Storing person in charge
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:153) - Saving Author.
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (SessionHelper.java:87) - Obteniendo usuario
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (SessionHelper.java:90) - Obteniendo usuario ahora => L0749001 - Lambolay, Marcos Santiago
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (SessionHelper.java:94) - Obteniendo usuario despues => L0749001 - Lambolay, Marcos Santiago
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:155) - Author saved.
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:167) - Getting own user´s groups from session.
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:169) - Groups retrieved: [AmbitoGrupoGD - uId: [0]
[1/9/06 12:33:00:328 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:179) - Group to add: RecursoGrupoGDPropioUsuario - uId: [0], Name: [0C0C1241ECompany]
[1/9/06 12:33:00:344 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:192) - Adding
[1/9/06 12:33:00:344 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:198) - Getting other users´ groups from session.
[1/9/06 12:33:00:344 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:200) - Groups retrieved: [AmbitoGrupoGD - uId: [0]
[1/9/06 12:33:00:344 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:210) - Group to add: RecursoGrupoGDOtrosUsuarios - uId: [0], Name: [0C0C1241ECompany]
[1/9/06 12:33:00:344 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:223) - Adding
[1/9/06 12:33:00:344 ART] 24171a94 SystemOut O DEBUG [Servlet.Engine.Transports : 3] (GuardarRecursoAction.java:247) - Before saving
[1/9/06 12:33:00:375 ART] 24171a94 SystemOut O ERROR [Servlet.Engine.Transports : 3] (TransactionAction.java:176) - exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of ar.com.bgba.ecompany.wfsi.Ayuda.?
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of ar.com.bgba.ecompany.wfsi.Ayuda.?
at net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java(Compiled Code))
at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:3990)
at net.sf.hibernate.impl.SessionImpl.copy(SessionImpl.java:3942)
at net.sf.hibernate.engine.Cascades$5.cascade(Cascades.java:132)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java(Compiled Code))
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java(Compiled Code))
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:872)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:3973)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:3938)
at ar.com.bgba.ecompany.wfsi.admin.action.GuardarRecursoAction.guardarOpciones(GuardarRecursoAction.java:294)
at ar.com.bgba.ecompany.wfsi.admin.action.GuardarRecursoAction.execute(GuardarRecursoAction.java:250)
at ar.com.bgba.ecompany.commons.struts.TransactionAction.execute(TransactionAction.java:148)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:120)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java(Compiled Code))
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java(Compiled Code))
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Caused by: java.lang.NullPointerException
at ar.com.bgba.ecompany.wfsi.Ayuda$$BulkBeanByCGLIB$$aba7849f.getPropertyValues(<generated>(Compiled Code))
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java(Inlined Compiled Code))
... 59 more
[1/9/06 12:33:00:375 ART] 24171a94 SystemOut O ERROR [Servlet.Engine.Transports : 3] (ExceptionHandler.java:43) - exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of ar.com.bgba.ecompany.wfsi.Ayuda.?
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) getter of ar.com.bgba.ecompany.wfsi.Ayuda.?
at net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java(Compiled Code))
at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:3990)
at net.sf.hibernate.impl.SessionImpl.copy(SessionImpl.java:3942)
at net.sf.hibernate.engine.Cascades$5.cascade(Cascades.java:132)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java(Compiled Code))
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java(Compiled Code))
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:872)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
at net.sf.hibernate.impl.SessionImpl.doCopy(SessionImpl.java:3973)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdateCopy(SessionImpl.java:3938)
at ar.com.bgba.ecompany.wfsi.admin.action.GuardarRecursoAction.guardarOpciones(GuardarRecursoAction.java:294)
at ar.com.bgba.ecompany.wfsi.admin.action.GuardarRecursoAction.execute(GuardarRecursoAction.java:250)
at ar.com.bgba.ecompany.commons.struts.TransactionAction.execute(TransactionAction.java:148)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServicingServletState.service(StrictLifecycleServlet.java:333)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:274)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:320)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:120)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java(Compiled Code))
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java(Compiled Code))
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Caused by: java.lang.NullPointerException
at ar.com.bgba.ecompany.wfsi.Ayuda$$BulkBeanByCGLIB$$aba7849f.getPropertyValues(<generated>(Compiled Code))
at net.sf.cglib.beans.BulkBean.getPropertyValues(BulkBean.java(Inlined Compiled Code))
... 59 more
Name and version of the database you are using:
Websphere 5.1 with Sql Server 2000