Hi

I'm using Spring with JSecurity for my web app. I was having problems with JSecurity's tags in JSP, as they were not getting the user roles, and they were available in my controllers and business objects. My first thought was that it was because ehcache configuration was not in place (used by JSecurity to cache permissions and roles). Then I set the JSecurity securityManager bean to be injected with a cacheManager configuration created using classpath config file (this step was not in the samples).

In JBoss logging I see that the securityManager is created with my configs, but it is also created other three times, all of them with default JSecurity config, which won't find any useful data. It is like whenever a new securityManager bean needs to be injected somewhere, it is recreated whatever or not is was already. Here is the (long) logs on security manager creation:

Code:
...
2009-07-02 10:02:05,593 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Eagerly caching bean 'cacheManager' to allow for resolving potential circular references
2009-07-02 10:02:06,359 DEBUG [org.jsecurity.spring.LifecycleBeanPostProcessor] Initializing bean [cacheManager]...
2009-07-02 10:02:06,375 DEBUG [org.jsecurity.cache.ehcache.EhCacheManager] cacheManager property not set.  Constructing CacheManager instance...
2009-07-02 10:02:07,718 DEBUG [org.jsecurity.io.ResourceUtils] Opening resource from class path [myconfig-ehcache.xml]...
2009-07-02 10:02:07,718 DEBUG [net.sf.ehcache.config.ConfigurationFactory] Configuring ehcache from InputStream
2009-07-02 10:02:07,718 DEBUG [net.sf.ehcache.config.DiskStoreConfiguration] Disk Store Path: C:\DOCUME~1\MYUSER\CONFIG~1\Temp\/jsecurity-mydiskstore
...
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.MemoryStore] Initialized net.sf.ehcache.store.LruMemoryStore for org.jsecurity.realm.SimpleAccountRealm.authorization
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.LruMemoryStore] org.jsecurity.realm.SimpleAccountRealm.authorization Cache: Using SpoolingLinkedHashMap implementation
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.Cache] Initialised cache: org.jsecurity.realm.SimpleAccountRealm.authorization
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.DiskStore] IOException reading index. Creating new index.
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.DiskStore] Index file C:\DOCUME~1\MYUSER\CONFIG~1\Temp\jsecurity-mydiskstore\jsecurity-activeSessionCache.index deleted.
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.DiskStore] Index file C:\DOCUME~1\MYUSER\CONFIG~1\Temp\jsecurity-mydiskstore\jsecurity-activeSessionCache.index created successfully
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.DiskStore] Index file dirty or empty. Deleting data file jsecurity-activeSessionCache.data
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.MemoryStore] Initialized net.sf.ehcache.store.LruMemoryStore for jsecurity-activeSessionCache
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.store.LruMemoryStore] jsecurity-activeSessionCache Cache: Using SpoolingLinkedHashMap implementation
2009-07-02 10:02:07,734 DEBUG [net.sf.ehcache.Cache] Initialised cache: jsecurity-activeSessionCache
2009-07-02 10:02:07,734 TRACE [org.jsecurity.cache.ehcache.EhCacheManager] instantiated Ehcache CacheManager instance.
2009-07-02 10:02:08,406 DEBUG [org.jsecurity.cache.ehcache.EhCacheManager] implicit cacheManager created successfully.
2009-07-02 10:02:08,406 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0'
...
...
2009-07-02 10:02:14,312 DEBUG [org.jsecurity.io.IniResource] Parsing [urls]
2009-07-02 10:02:14,312 DEBUG [org.jsecurity.mgt.CachingSecurityManager] Attempting to initialize default CacheManager using EhCache...
2009-07-02 10:02:14,312 DEBUG [org.jsecurity.cache.ehcache.EhCacheManager] cacheManager property not set.  Constructing CacheManager instance...
2009-07-02 10:02:48,656 DEBUG [org.jsecurity.io.ResourceUtils] Opening resource from class path [org/jsecurity/cache/ehcache/ehcache.xml]...
2009-07-02 10:02:48,656 DEBUG [net.sf.ehcache.config.ConfigurationFactory] Configuring ehcache from InputStream
2009-07-02 10:02:48,671 DEBUG [net.sf.ehcache.config.DiskStoreConfiguration] Disk Store Path: C:\DOCUME~1\MYUSER\CONFIG~1\Temp\/jsecurity-ehcache
2009-07-02 10:02:48,671 WARN  [net.sf.ehcache.CacheManager] Creating a new instance of CacheManager using the diskStorePath "C:\DOCUME~1\MYUSER\CONFIG~1\Temp\/jsecurity-ehcache" which is already used by an existing CacheManager.
The source of the configuration was InputStream sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream@1542688.
The diskStore path for this CacheManager will be set to C:\DOCUME~1\MYUSER\CONFIG~1\Temp\/jsecurity-ehcache\ehcache_auto_created_1246539768671.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
...
2009-07-02 10:02:48,703 DEBUG [net.sf.ehcache.store.DiskStore] Deleting data file org.jsecurity.realm.text.PropertiesRealm-0-accounts.data
2009-07-02 10:02:48,718 DEBUG [net.sf.ehcache.store.MemoryStore] Initialized net.sf.ehcache.store.LruMemoryStore for org.jsecurity.realm.text.PropertiesRealm-0-accounts
2009-07-02 10:02:48,718 DEBUG [net.sf.ehcache.store.LruMemoryStore] org.jsecurity.realm.text.PropertiesRealm-0-accounts Cache: Using SpoolingLinkedHashMap implementation
2009-07-02 10:02:48,718 DEBUG [net.sf.ehcache.Cache] Initialised cache: org.jsecurity.realm.text.PropertiesRealm-0-accounts
2009-07-02 10:02:48,718 TRACE [org.jsecurity.cache.ehcache.EhCacheManager] instantiated Ehcache CacheManager instance.
2009-07-02 10:02:51,921 DEBUG [org.jsecurity.cache.ehcache.EhCacheManager] implicit cacheManager created successfully.
2009-07-02 10:02:51,921 INFO  [org.jsecurity.web.DefaultWebSecurityManager] http mode - enabling ServletContainerSessionManager (Http Sessions)
2009-07-02 10:02:52,078 TRACE [org.jsecurity.config.ReflectionBuilder] Applying property [loginUrl] value [/web/login] on object of type [org.jsecurity.web.filter.authc.UserFilter]
These are just the third and fourth creation log blocks. The first one I'm not sure when happens, the second seems at securityManager creation, the third and the one with correct config is at securityManager caching (first one above), and the fourth when parsing [url] in web.xml (url pattern permissions in JSecurity).

I googled, but I found not similar situation.

Another important info: all this JSecurity config is defined in a common shared application (link), so that the two other WAR contexts that I use can share the same beans. I need this so that both WARs can use the same DAO and Service beans. Right now, just one of them uses these common beans, the other one is still plain JSP, no business methods calls.

I know it is confuse... it is a lot of details, but I did what I could for the max message size. Any missing info, please say it and I'll post.
Any help is greatly appreciated!

Thanks!