shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nariman (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (SHIRO-154) Adding ehcahe CacheManager to Spring Sample failes
Date Tue, 11 May 2010 09:03:42 GMT

    [ https://issues.apache.org/jira/browse/SHIRO-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12866100#action_12866100
] 

Nariman edited comment on SHIRO-154 at 5/11/10 5:03 AM:
--------------------------------------------------------

cause of this NPE is that org.apache.shiro.cache.ehcache.EhCacheManager do not create new
instance of EhCache by some reasons if you pass only config file as property

to avoid this NPE init ehCache by yourself and pass it to  org.apache.shiro.cache.ehcache.EhCacheManager
 as property too

for example like this

 <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        <property name="cacheManagerConfigFile" value="file:${webapp.root}/WEB-INF/ehcache.xml"/>
        <property name="cacheManager" ref="ehCacheManager"/>
    </bean>

    <bean id="ehCacheManager"  class="net.sf.ehcache.CacheManager">
        <constructor-arg index="0" value="${webapp.root}/WEB-INF/ehcache.xml"/>
    </bean>

      was (Author: nariman):
    cause of this NPE is that org.apache.shiro.cache.ehcache.EhCacheManager do not create
new instance of EhCache by some reasons if you pass only config file as property

to avoid this NPE init ehCache by yourself and pass it to  org.apache.shiro.cache.ehcache.EhCacheManager
 as property too

for examaple like this

 <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        <property name="cacheManagerConfigFile" value="file:${webapp.root}/WEB-INF/ehcache.xml"/>
        <property name="cacheManager" ref="ehCacheManager"/>
    </bean>

    <bean id="ehCacheManager"  class="net.sf.ehcache.CacheManager">
        <constructor-arg index="0" value="${webapp.root}/WEB-INF/ehcache.xml"/>
    </bean>
  
> Adding ehcahe CacheManager to Spring Sample failes 
> ---------------------------------------------------
>
>                 Key: SHIRO-154
>                 URL: https://issues.apache.org/jira/browse/SHIRO-154
>             Project: Shiro
>          Issue Type: Bug
>          Components: Authentication (log-in), Authorization (access control) , Caching
, Integration: Spring, Realms , Session Management, Web
>    Affects Versions: Incubation
>         Environment: Windows XP, Netbeans, 
>            Reporter: Nariman
>
> after I updated to new Shiro version from svn I cannot initialize and include org.apache.shiro.cache.ehcache.EhCacheManager
to Security manager any more.
> could you please describe how to do it. I cannot afford to use default "in memory" implementation
> I use as example "Sample Shiro Spring". it just does not work and gives me NPE 
> how to reproduce: open sample project "Apache Shiro :: Samples :: Spring". 
> add library for org.apache.shiro.cache.ehcache.EhCacheManager (artifactId shiro-ehcache)
> add to applicationContext.xml
> <bean id="cacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
>      <property name="cacheManagerConfigFile" value="classpath:ehcache.xml"/>
> </bean>
> and add this cache manager to "jdbcRealm" bean
> <property name="cacheManager" ref="cacheManager"/>
> and get NPE on project run
> 2010-04-30 10:42:29,734 TRACE [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor]
- No authorization advice explicitly configured via the 'advice' property.  Attempting to
set default instance of type [org.apache.shiro.spring.security.interceptor.AopAllianceAnnotationsAuthorizingMethodInterceptor]

> 2010-04-30 10:42:29,781 TRACE [org.apache.shiro.realm.AuthorizingRealm] - Initializing
authorization cache. 
> 2010-04-30 10:42:29,781 DEBUG [org.apache.shiro.realm.AuthorizingRealm] - No cache implementation
set.  Checking cacheManager... 
> 2010-04-30 10:42:29,781 DEBUG [org.apache.shiro.realm.AuthorizingRealm] - CacheManager
[org.apache.shiro.cache.ehcache.EhCacheManager@baa573] has been configured.  Building authorization
cache named [org.apache.shiro.realm.jdbc.JdbcRealm-0-authorization] 
> 2010-04-30 10:42:29,781 TRACE [org.apache.shiro.cache.ehcache.EhCacheManager] - Loading
a new EhCache cache named [org.apache.shiro.realm.jdbc.JdbcRealm-0-authorization] 
> 2010-04-30 10:42:29,875 ERROR [org.springframework.web.context.ContextLoader] - Context
initialization failed 
> org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'shiroFilter' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot
resolve reference to bean 'securityManager' while setting bean property 'securityManager';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'securityManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Cannot resolve reference to bean 'jdbcRealm' while setting bean property 'realm'; nested exception
is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'jdbcRealm' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting
property values; nested exception is org.springframework.beans.PropertyBatchUpdateException;
nested PropertyAccessExceptions (1) are:
> PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property
'cacheManager' threw exception; nested exception is java.lang.NullPointerException
>         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
>         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
>         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
>         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
>         at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)
>         at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:605)
>         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:365)
>         at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
>         at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
>         at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
>         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
>         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
>         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
>         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
>         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
>         at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
>         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:514)
>         at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1288)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
>         at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
>         at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
>         at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1473)
>         at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:824)
>         at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:350)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>         at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:196)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
>         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
>         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
>         at java.lang.Thread.run(Thread.java:619)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'securityManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Cannot resolve reference to bean 'jdbcRealm' while setting bean property 'realm'; nested exception
is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'jdbcRealm' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting
property values; nested exception is org.springframework.beans.PropertyBatchUpdateException;
nested PropertyAccessExceptions (1) are:
> PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property
'cacheManager' threw exception; nested exception is java.lang.NullPointerException
>         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
>         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
>         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
>         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
>         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
>         ... 54 more
> Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'jdbcRealm' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException;
nested PropertyAccessExceptions (1) are:
> PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property
'cacheManager' threw exception; nested exception is java.lang.NullPointerException
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
>         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
>         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
>         at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
>         ... 67 more
> Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions
(1) are:
> PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property
'cacheManager' threw exception; nested exception is java.lang.NullPointerException
>         at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
>         at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)
>         ... 78 more
> Apr 30, 2010 10:42:30 AM org.apache.catalina.core.StandardContext start
> SEVERE: Error listenerStart
> Apr 30, 2010 10:42:30 AM org.apache.catalina.core.StandardContext start
> SEVERE: Context [/samples-spring-1.0-incubating-SNAPSHOT] startup failed due to previous
errors

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message