[
http://jira.jboss.com/jira/browse/JBSEAM-1114?page=comments#action_12362802 ]
Shane Bryzak commented on JBSEAM-1114:
--------------------------------------
What if we just added a static disableChecks() method to EntitySecurityListener, that set
a static variable disabled = true. Then each of the listener methods postLoad(),
prePersist(), etc could only perform the check if the listener isn't disabled. Unit
tests could then call disableChecks() manually.
Disable EntitySecurityListener problem in unit tests
----------------------------------------------------
Key: JBSEAM-1114
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1114
Project: JBoss Seam
Issue Type: Feature Request
Affects Versions: 1.2.0.GA
Environment: Windows XP SP2, JBoss AS EJB3 profile 4.0.5.GA
Reporter: Artur Chyzy
Assigned To: Shane Bryzak
Priority: Minor
Fix For: 1.3.0.BETA1
When putting to orm.xml config for EntitySecurityListener
<persistence-unit-metadata>
<persistence-unit-defaults>
<entity-listeners>
<entity-listener
class="org.jboss.seam.security.EntitySecurityListener"/>
</entity-listeners>
</persistence-unit-defaults>
</persistence-unit-metadata>
and trying to run unit tests the following exception is thrown
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.jav
a: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
Without EntitySecurityListener config in orm.xml tests runs fine.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira