[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5702) Hibernate always registers JACC event listeners regardless of whether that is enabled or not which causes unecessary exceptions to be thrown.
Eduardo Born (JIRA)
noreply at atlassian.com
Sat Oct 30 17:31:47 EDT 2010
Hibernate always registers JACC event listeners regardless of whether that is enabled or not which causes unecessary exceptions to be thrown.
---------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5702
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5702
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.6
Reporter: Eduardo Born
Hibernate always registers JACC event listeners regardless of whether JACC has been enabled or not (by defining the property hibernate.jacc.enabled in the configurations).
The JACC even listeners cause exceptions to be thrown in several situations when Hibernate is not running as part of a container. The most common exception I've seen so far is the "java.lang.IllegalArgumentException: unknown handler key"
Hibernate should only register the JACC listeners when JACC is enabled.
The fix seems to be in the EventListenerConfigurator class. A simple check for the hibernate.jacc.enabled property should be done before adding any of the JACC event listeners (JACCPreDeleteEventListener, JACCPreLoadEventListener, JACCPreUpdateEventListener, JACCPreInsertEventListener).
I believe a simple check like
if ( properties.containsKey( AvailableSettings.JACC_ENABLED ) ) {
...
}
should be performed before adding them.
In my case these listeners cause exceptions like these to be thrown in a few situations:
java.lang.IllegalArgumentException: unknown handler key
at javax.security.jacc.PolicyContext.getContext(PolicyContext.java:280)
at org.hibernate.secure.JACCPermissions$PolicyContextActions$2.getContextSubject(JACCPermissions.java:111)
at org.hibernate.secure.JACCPermissions.getContextSubject(JACCPermissions.java:120)
at org.hibernate.secure.JACCPermissions.checkPermission(JACCPermissions.java:59)
at org.hibernate.secure.JACCPreLoadEventListener.onPreLoad(JACCPreLoadEventListener.java:53)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:149)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:898)
...so I have to manually remove these listeners.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list