how to use Ehcache 3 + in shirt?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to use Ehcache 3 + in shirt?

Mike Guo
hello.  all.

is there anybody have experiences for use ehcache 3 in Shiro? 


I tried use it like this:

@Bean
public DefaultWebSecurityManager securityManager() throws IOException {



SessionManager sessionManager = new DefaultWebSessionManager();


EhCacheManager cacheManager = new EhCacheManager();
cacheManager.setCacheManagerConfigFile(
new ClassPathResource("session-cache.xml").getFile().getAbsolutePath()
);


DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();


securityManager.setRealm(myRealm());
securityManager.setSessionManager(sessionManager);
securityManager.setCacheManager(cacheManager);



return securityManager;


}



and the content in session-cache.xml like this:


<?xml version="1.0" encoding="UTF-8"?>

<config

  <cache alias="shiro-activeSessionCache"> 
    <resources>
      <heap unit="entries">2000</heap> 
      <offheap unit="MB">500</offheap> 
    </resources>
  </cache>


</config>



but system report a error.   

... 89 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor]: Factory method 'authorizationAttributeSourceAdvisor' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in com.fbcglobal.customer.config.RootConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.web.mgt.DefaultWebSecurityManager]: Factory method 'securityManager' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:6: Element <config> does not allow attribute "xmlns:xsi".
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 106 more



it that mean  Shiro doesn’t support ehcache 3?



if it support it,  would you point me a way?


Many thanks


Mike

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use Ehcache 3 + in shirt?

Mike Guo
I am so sorry. Typo.  Shiro

thanks

Mike


在 2017年8月12日,下午5:24,Mike Guo <[hidden email]> 写道:

hello.  all.

is there anybody have experiences for use ehcache 3 in Shiro? 


I tried use it like this:

@Bean
public DefaultWebSecurityManager securityManager() throws IOException {


SessionManager sessionManager = new DefaultWebSessionManager();

EhCacheManager cacheManager = new EhCacheManager();
cacheManager.setCacheManagerConfigFile(
new ClassPathResource("session-cache.xml").getFile().getAbsolutePath()
);

DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();

securityManager.setRealm(myRealm());
securityManager.setSessionManager(sessionManager);
securityManager.setCacheManager(cacheManager);


return securityManager;

}


and the content in session-cache.xml like this:

<?xml version="1.0" encoding="UTF-8"?>

<config

  <cache alias="shiro-activeSessionCache"> 
    <resources>
      <heap unit="entries">2000</heap> 
      <offheap unit="MB">500</offheap> 
    </resources>
  </cache>


</config>



but system report a error.   

... 89 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor]: Factory method 'authorizationAttributeSourceAdvisor' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in com.fbcglobal.customer.config.RootConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.web.mgt.DefaultWebSecurityManager]: Factory method 'securityManager' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:6: Element <config> does not allow attribute "xmlns:xsi".
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 106 more



it that mean  Shiro doesn’t support ehcache 3?



if it support it,  would you point me a way?


Many thanks


Mike


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use Ehcache 3 + in shirt?

Mike Guo
In reply to this post by Mike Guo
I am so sorry,  Typo: Shiro


Mike

在 2017年8月12日,下午5:24,Mike Guo <[hidden email]> 写道:

hello.  all.

is there anybody have experiences for use ehcache 3 in Shiro? 


I tried use it like this:

@Bean
public DefaultWebSecurityManager securityManager() throws IOException {


SessionManager sessionManager = new DefaultWebSessionManager();

EhCacheManager cacheManager = new EhCacheManager();
cacheManager.setCacheManagerConfigFile(
new ClassPathResource("session-cache.xml").getFile().getAbsolutePath()
);

DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();

securityManager.setRealm(myRealm());
securityManager.setSessionManager(sessionManager);
securityManager.setCacheManager(cacheManager);


return securityManager;

}


and the content in session-cache.xml like this:

<?xml version="1.0" encoding="UTF-8"?>

<config

  <cache alias="shiro-activeSessionCache"> 
    <resources>
      <heap unit="entries">2000</heap> 
      <offheap unit="MB">500</offheap> 
    </resources>
  </cache>


</config>



but system report a error.   

... 89 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor]: Factory method 'authorizationAttributeSourceAdvisor' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in com.fbcglobal.customer.config.RootConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.web.mgt.DefaultWebSecurityManager]: Factory method 'securityManager' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:6: Element <config> does not allow attribute "xmlns:xsi".
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 106 more



it that mean  Shiro doesn’t support ehcache 3?



if it support it,  would you point me a way?


Many thanks


Mike


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use Ehcache 3 + in shirt?

Mike Guo
In reply to this post by Mike Guo
finally, I googled one project shiro-ehcache3. 
here it is :

but after I did testing, I found there is a bug in class: 

line: 164

it strip the prefix,  so, when the code use the result as URL parameter, it always throw a exception.  

these code can be used just need comment line 164.


thanks


Mike


在 2017年8月12日,下午5:24,Mike Guo <[hidden email]> 写道:

hello.  all.

is there anybody have experiences for use ehcache 3 in Shiro? 


I tried use it like this:

@Bean
public DefaultWebSecurityManager securityManager() throws IOException {


SessionManager sessionManager = new DefaultWebSessionManager();

EhCacheManager cacheManager = new EhCacheManager();
cacheManager.setCacheManagerConfigFile(
new ClassPathResource("session-cache.xml").getFile().getAbsolutePath()
);

DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();

securityManager.setRealm(myRealm());
securityManager.setSessionManager(sessionManager);
securityManager.setCacheManager(cacheManager);


return securityManager;

}


and the content in session-cache.xml like this:

<?xml version="1.0" encoding="UTF-8"?>

<config

  <cache alias="shiro-activeSessionCache"> 
    <resources>
      <heap unit="entries">2000</heap> 
      <offheap unit="MB">500</offheap> 
    </resources>
  </cache>


</config>



but system report a error.   

... 89 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor]: Factory method 'authorizationAttributeSourceAdvisor' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in com.fbcglobal.customer.config.RootConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.web.mgt.DefaultWebSecurityManager]: Factory method 'securityManager' threw exception; nested exception is org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: Error configuring from input stream. Initial cause was null:6: Element <config> does not allow attribute "xmlns:xsi".
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 106 more



it that mean  Shiro doesn’t support ehcache 3?



if it support it,  would you point me a way?


Many thanks


Mike


Loading...