java.lang.IllegalArgumentException: unknown handler key

Hibernate JIRA | Eduardo Born | 6 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    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.

    Hibernate JIRA | 6 years ago | Eduardo Born
    java.lang.IllegalArgumentException: unknown handler key
  2. 0

    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.

    Hibernate JIRA | 6 years ago | Eduardo Born
    java.lang.IllegalArgumentException: unknown handler key
  3. 0

    Hibernate Community • View topic - JPA stand alone programmatic setup

    hibernate.org | 1 year ago
    java.lang.IllegalArgumentException: No PolicyContextHandler for key=javax.security.auth.Subject.container
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Access session from DatabaseServerLoginModule for jBoss 6?

    Coderanch | 4 years ago | Chris Whites
    java.lang.IllegalArgumentException: unknown handler key
  6. 0

    PolicyContext in Tomcat not being set in Tomcat 6.0.44

    Coderanch | 11 months ago | Saurabh Sam
    java.lang.IllegalArgumentException: unknown handler key

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      unknown handler key

      at javax.security.jacc.PolicyContext.getContext()
    2. JavaEE 7
      PolicyContext.getContext
      1. javax.security.jacc.PolicyContext.getContext(PolicyContext.java:280)
      1 frame
    3. Hibernate
      JACCPreLoadEventListener.onPreLoad
      1. org.hibernate.secure.JACCPermissions$PolicyContextActions$2.getContextSubject(JACCPermissions.java:111)
      2. org.hibernate.secure.JACCPermissions.getContextSubject(JACCPermissions.java:120)
      3. org.hibernate.secure.JACCPermissions.checkPermission(JACCPermissions.java:59)
      4. org.hibernate.secure.JACCPreLoadEventListener.onPreLoad(JACCPreLoadEventListener.java:53)
      4 frames
    4. Hibernate
      Loader.initializeEntitiesAndCollections
      1. org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:149)
      2. org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:898)
      2 frames