3 Replies Latest reply on Oct 26, 2007 4:20 AM by Nicolas Germeau

    Identity check during hibernate operaiotn in application com

    rpochet Newbie

      Hi,

      I'm trying to execute database insert during creation of an application scope component

      @Scope(value=ScopeType.APPLICATION)
      @Name("initialisation")
      @Startup(depends="hibernateSessionFactory")
      public class Initialisation
      {
       @Logger
       private Log logger = null;
      
       @In
       private Session homeDatabase = null;
      
       @Create
       @CreateProcess(definition="discoveryAll")
       public void init()
       {
       homeDatabase.save(...);
       }
       {


      but I got a
      java.lang.IllegalStateException: No active session context
       at org.jboss.seam.security.Identity.instance(Identity.java:157)
       at org.jboss.seam.security.HibernateSecurityInterceptor.onSave(HibernateSecurityInterceptor.java:73)
       at org.hibernate.event.def.AbstractSaveEventListener.substituteValuesIfNecessary(AbstractSaveEventListener.java:394)
       at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:270)
       at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
       at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
       at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
       at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
       at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
       at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
       at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
       at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
       at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
       at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
       at org.hibernate.search.impl.FullTextSessionImpl.save(FullTextSessionImpl.java:439)
       at org.jboss.seam.persistence.HibernateSessionProxy.save(HibernateSessionProxy.java:335)
      


      because there is no identity currently defined.
      By setting
      Identity.setSecurityEnabled(false);

      it works but this disabled all security check.

      Any idea on how to handle such feature?

      Thanks,