2 Replies Latest reply on Mar 26, 2007 11:24 PM by Shane Bryzak

    Tests errors

    Artur Chyzy Newbie

      Hello. I'm trying to run some tests.
      When i put following config to orm.xml

      
       <persistence-unit-metadata>
       <persistence-unit-defaults>
       <entity-listeners>
       <entity-listener class="org.jboss.seam.security.EntitySecurityListener"/>
       </entity-listeners>
       </persistence-unit-defaults>
       </persistence-unit-metadata>
      


      i've got this error:

      
      java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
       at org.hibernate.ejb.event.ListenerCallback.invoke(ListenerCallback.java:33)
       at org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:78)
       at org.hibernate.ejb.event.EntityCallbackHandler.postLoad(EntityCallbackHandler.java:71)
       at org.hibernate.ejb.event.EJB3PostLoadEventListener.onPostLoad(EJB3PostLoadEventListener.java:35)
       at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:201)
       at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
       at org.hibernate.loader.Loader.doQuery(Loader.java:717)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
       at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
       at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
       at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
       at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2821)
       at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:370)
       at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:351)
       at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:122)
       at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:178)
       at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:86)
       at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:871)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:801)
       at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:155)
       at pl.alternativ.med.pacjent.DeklaracjaPOZUnitTest.utworz(DeklaracjaPOZUnitTest.java:78)
       at org.hibernate.ejb.event.ListenerCallback.invoke(ListenerCallback.java:30)
       ... 42 more
      Caused by: java.lang.IllegalStateException: No active session context
       at org.jboss.seam.security.Identity.instance(Identity.java:108)
       at org.jboss.seam.security.EntitySecurityListener.postLoad(EntitySecurityListener.java:24)
       ... 47 more
      ... Removed 26 stack frames
      
      

      I think seam is trying to get identity to check restrictions (i think it shouldn't in unit tests). If this situation is fine then i need to create two separate configs for tests (unit and integration).

      Without it tests works fine.



      //-------------------------------------------------------------------------

      Also when trying to run integration tests, config from pages.xml file are not read correctly - it doesn't start conversation

      I used following config

      <navigation from-action="#{someBean.select}">
       <begin-conversation nested="true"/>
       <redirect view-id="/edit.jspx" />
       </navigation>
      


      When i put some object to conversation scope using
      Contexts.getConversationContext().set()

      the value is not in context after new request (even if i put the same cid to it). This is my code:
      new FacesRequest("/edit.jspx", cid)
      
      


      I changed start and end conversation definition from ejb3 bean annotation to local pages.xml file which doesn't work for tests (but works fine when application is running).


      Please post some help if i made mistake. I'm out of ideas.
      I marked my questions

      Artur