[ https://issues.apache.org/jira/browse/KNOX-1165?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kevin Risden updated KNOX-1165: ------------------------------- Description: *Solution:* See updated documentation here: https://knox.apache.org/books/knox-1-2-0/user-guide.html#LDAP+Authentication+Caching *Problem* Issue is described on the note "Error:Shiro environment initialization failed" when starting Knox; {code:java} ERROR env.EnvironmentLoader (EnvironmentLoader.java:initEnvironment(146)) - Shiro environment initialization failed org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following {code} After implementing the solution of creating a new ehcache.xml and reference as <ehcache name="knox-mytopology1"> we still see the issue: {code:java} Caused by: net.sf.ehcache.CacheException: Another CacheManager with same name 'knox-tp' already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: {code} *Steps to reproduce* When enabling the following parameters: {code:java} <param> <name>main.cacheManager</name> <value>org.apache.shiro.cache.ehcache.EhCacheManager</value> </param> <param> <name>main.securityManager.cacheManager</name> <value>$cacheManager</value> </param> <param> <name>main.ldapRealm.authenticationCachingEnabled</name> <value>true</value> </param>{code} *More Info* This KNOX-804 was open to solve this same issue but is not documented anywhere, but we can see the coding changes in GitHub. * The issue seems to be a racing condition on the Shiro lib class, in which depending on the processing power of the server there are two threads within the same "if" statement; ** ref: [https://github.com/apache/shiro/blob/master/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCacheManager.java] * The Default constructor only builds the Object, and does not do much: * {code:java} /**Default no argument constructor*/ public EhCacheManager() { }{code} * Accordingly with shiro documentation: ** {code:java} /** Initializes this instance. <p/> If a {@link #setCacheManager CacheManager} has been explicitly set (e.g. via Dependency Injection or programmatically) prior to calling this method, this method does nothing. <p/> However, if no {@code CacheManager} has been set, the default Ehcache singleton will be initialized, where Ehcache will look for an {@code ehcache.xml} file at the root of the classpath. If one is not found, Ehcache will use its own failsafe configuration file. <p/> Because Shiro cannot use the failsafe defaults (fail-safe expunges cached objects after 2 minutes, something not desirable for Shiro sessions), this class manages an internal default configuration for this case. @throws org.apache.shiro.cache.CacheException if there are any CacheExceptions thrown by EhCache. @see net.sf.ehcache.CacheManager#create */ public final void init() throws CacheException { ensureCacheManager(); } private net.sf.ehcache.CacheManager ensureCacheManager() { ***It fails in here. }{code} * This is the head of the exception: The source of the existing CacheManager is: ** {code:java} InputStreamConfigurationSource [stream=java.io.BufferedInputStream@675ffd1d] at org.apache.shiro.cache.ehcache.EhCacheManager.ensureCacheManager(EhCacheManager.java:224) at org.apache.shiro.cache.ehcache.EhCacheManager.init(EhCacheManager.java:199) at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:45) at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:40){code} * Starting from KNOX-804, the KnoxCacheManager was introduced. Remember that Init() will do nothing if anything in case the setCacheManager is explicitly set. ** ref: [https://github.com/apache/knox/commit/f9d8e07d768459240c8665f139cc140575dc5216] was: *Solution: See updated documentation here:* *Problem* Issue is described on the note "Error:Shiro environment initialization failed" when starting Knox; {code:java} ERROR env.EnvironmentLoader (EnvironmentLoader.java:initEnvironment(146)) - Shiro environment initialization failed org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Another unnamed CacheManager already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following {code} After implementing the solution of creating a new ehcache.xml and reference as <ehcache name="knox-mytopology1"> we still see the issue: {code:java} Caused by: net.sf.ehcache.CacheException: Another CacheManager with same name 'knox-tp' already exists in the same VM. Please provide unique names for each CacheManager in the config or do one of following: {code} *Steps to reproduce* When enabling the following parameters: {code:java} <param> <name>main.cacheManager</name> <value>org.apache.shiro.cache.ehcache.EhCacheManager</value> </param> <param> <name>main.securityManager.cacheManager</name> <value>$cacheManager</value> </param> <param> <name>main.ldapRealm.authenticationCachingEnabled</name> <value>true</value> </param>{code} *More Info* This KNOX-804 was open to solve this same issue but is not documented anywhere, but we can see the coding changes in GitHub. * The issue seems to be a racing condition on the Shiro lib class, in which depending on the processing power of the server there are two threads within the same "if" statement; ** ref: [https://github.com/apache/shiro/blob/master/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCacheManager.java] * The Default constructor only builds the Object, and does not do much: * {code:java} /**Default no argument constructor*/ public EhCacheManager() { }{code} * Accordingly with shiro documentation: ** {code:java} /** Initializes this instance. <p/> If a {@link #setCacheManager CacheManager} has been explicitly set (e.g. via Dependency Injection or programmatically) prior to calling this method, this method does nothing. <p/> However, if no {@code CacheManager} has been set, the default Ehcache singleton will be initialized, where Ehcache will look for an {@code ehcache.xml} file at the root of the classpath. If one is not found, Ehcache will use its own failsafe configuration file. <p/> Because Shiro cannot use the failsafe defaults (fail-safe expunges cached objects after 2 minutes, something not desirable for Shiro sessions), this class manages an internal default configuration for this case. @throws org.apache.shiro.cache.CacheException if there are any CacheExceptions thrown by EhCache. @see net.sf.ehcache.CacheManager#create */ public final void init() throws CacheException { ensureCacheManager(); } private net.sf.ehcache.CacheManager ensureCacheManager() { ***It fails in here. }{code} * This is the head of the exception: The source of the existing CacheManager is: ** {code:java} InputStreamConfigurationSource [stream=java.io.BufferedInputStream@675ffd1d] at org.apache.shiro.cache.ehcache.EhCacheManager.ensureCacheManager(EhCacheManager.java:224) at org.apache.shiro.cache.ehcache.EhCacheManager.init(EhCacheManager.java:199) at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:45) at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:40){code} * Starting from KNOX-804, the KnoxCacheManager was introduced. Remember that Init() will do nothing if anything in case the setCacheManager is explicitly set. ** ref: [https://github.com/apache/knox/commit/f9d8e07d768459240c8665f139cc140575dc5216] > Another unnamed CacheManager already exists in the same VM > ---------------------------------------------------------- > > Key: KNOX-1165 > URL: https://issues.apache.org/jira/browse/KNOX-1165 > Project: Apache Knox > Issue Type: Bug > Components: Server, Site > Affects Versions: 0.12.0, 0.13.0, 0.14.0, 1.0.0, 1.1.0 > Environment: JDK 1.8 > CentOS-6 (64bit) > Reporter: Ernani Pereira de Mattos Junior > Assignee: Kevin Risden > Priority: Critical > Fix For: 1.2.0 > > > *Solution:* See updated documentation here: > https://knox.apache.org/books/knox-1-2-0/user-guide.html#LDAP+Authentication+Caching > *Problem* > Issue is described on the note "Error:Shiro environment initialization > failed" when starting Knox; > {code:java} > ERROR env.EnvironmentLoader (EnvironmentLoader.java:initEnvironment(146)) - > Shiro environment initialization failed > org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: > Another unnamed CacheManager already exists in the same VM. Please provide > unique names for each CacheManager in the config or do one of following {code} > After implementing the solution of creating a new ehcache.xml and reference > as <ehcache name="knox-mytopology1"> we still see the issue: > {code:java} > Caused by: net.sf.ehcache.CacheException: Another CacheManager with same name > 'knox-tp' already exists in the same VM. Please provide unique names for each > CacheManager in the config or do one of following: {code} > *Steps to reproduce* > When enabling the following parameters: > {code:java} > <param> > <name>main.cacheManager</name> > <value>org.apache.shiro.cache.ehcache.EhCacheManager</value> > </param> > <param> > <name>main.securityManager.cacheManager</name> > <value>$cacheManager</value> > </param> > <param> > <name>main.ldapRealm.authenticationCachingEnabled</name> > <value>true</value> > </param>{code} > *More Info* > This KNOX-804 was open to solve this same issue but is not documented > anywhere, but we can see the coding changes in GitHub. > * The issue seems to be a racing condition on the Shiro lib class, in which > depending on the processing power of the server there are two threads within > the same "if" statement; > ** ref: > [https://github.com/apache/shiro/blob/master/support/ehcache/src/main/java/org/apache/shiro/cache/ehcache/EhCacheManager.java] > * The Default constructor only builds the Object, and does not do much: > * > {code:java} > /**Default no argument constructor*/ > public EhCacheManager() { > }{code} > * Accordingly with shiro documentation: > ** > {code:java} > /** > Initializes this instance. > <p/> > If a {@link #setCacheManager CacheManager} has been explicitly set (e.g. via > Dependency Injection or programmatically) prior to calling this > method, this method does nothing. > <p/> > However, if no {@code CacheManager} has been set, the default Ehcache > singleton will be initialized, where Ehcache will look for an {@code > ehcache.xml} file at the root of the classpath. If one is not found, Ehcache > will use its own failsafe configuration file. > <p/> > Because Shiro cannot use the failsafe defaults (fail-safe expunges cached > objects after 2 minutes, something not desirable for Shiro sessions), this > class manages an internal default configuration for this case. > @throws org.apache.shiro.cache.CacheException if there are any > CacheExceptions thrown by EhCache. > @see net.sf.ehcache.CacheManager#create > */ > public final void init() throws CacheException { ensureCacheManager(); } > private net.sf.ehcache.CacheManager ensureCacheManager() > { ***It fails in here. }{code} > * This is the head of the exception: The source of the existing CacheManager > is: > ** > {code:java} > InputStreamConfigurationSource [stream=java.io.BufferedInputStream@675ffd1d] > at > org.apache.shiro.cache.ehcache.EhCacheManager.ensureCacheManager(EhCacheManager.java:224) > at > org.apache.shiro.cache.ehcache.EhCacheManager.init(EhCacheManager.java:199) > at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:45) at > org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:40){code} > * Starting from KNOX-804, the KnoxCacheManager was introduced. Remember that > Init() will do nothing if anything in case the setCacheManager is explicitly > set. > ** ref: > [https://github.com/apache/knox/commit/f9d8e07d768459240c8665f139cc140575dc5216] -- This message was sent by Atlassian JIRA (v7.6.3#76005)