PDA

View Full Version : Problem with userCache using ehCache.


nicholsl
Oct 14th, 2004, 05:09 AM
I'm in the process of integrating Acegi Security into a project I'm working on, and have come across a strange problem when running unit tests.

I have implemented my own authorizationDao, and setup a userCache to use the ehCache mechanism.

When I run the tests that call the authenticationDao.lookupByUsername() method, I get no problems. However, if I run other tests that do not use the lookupByUsername() method of the authenticationDao, I'm getting the following exception being thrown when the spring context(s) are closed:

09:43:07,437 XXX ERROR DefaultListableBeanFactory:1145 - destroy() on bean with name 'userCache' threw an exception
java.lang.NullPointerException
at net.sf.acegisecurity.providers.dao.cache.EhCacheBa sedUserCache.destroy(EhCacheBasedUserCache.java:11 3)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.destroyBean(AbstractAut owireCapableBeanFactory.java:1142)
at org.springframework.beans.factory.support.Abstract BeanFactory.destroySingleton(AbstractBeanFactory.j ava:428)
at org.springframework.beans.factory.support.Abstract BeanFactory.destroySingletons(AbstractBeanFactory. java:414)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.destroySingletons(Abstr actAutowireCapableBeanFactory.java:1096)
at org.springframework.context.support.AbstractApplic ationContext.close(AbstractApplicationContext.java :420)
at com.du.eproc.dao.DAOTestBase.tearDown(DAOTestBase. java:39)
at com.du.eproc.dao.OrganisationDAOTest.tearDown(Orga nisationDAOTest.java:33)


Im using ehCache 0.9, although it looks like Acegi uses ehCache 0.7 ? I'm setting the userCache to use the acegi ehCache mechanism in my spring context file:

<bean
id="userCache"
class="net.sf.acegisecurity.providers.dao.cache.EhCacheBa sedUserCache">
<property name="minutesToIdle">
<value>5</value>
</property>
</bean>


It looks like (and I may be wrong) that if nothing is put in the userCache, then there is a problem when the cache is destroyed.

Any pointers ?

Thanks

Lawrie Nichols

nicholsl
Oct 14th, 2004, 05:20 AM
Apologies, I've just found the solution elsewhere in this forum (must bone up on my search skills).

Lawrie