Hi there.
I have a class called LocaleInterceptor that implements HandlerInterceptor which filters some requests to the webapp. It has a dependency on a LocaleManager which looks like this:
There is another bean which has a dependency on LocaleManager:Code:<bean id="localeInterceptor" class="net.urbanguru.wanep.web.LocaleInterceptor"> <property name="localeManager"><ref bean="wanepLocaleManager" /></property> </bean> <bean id="wanepLocaleManager" class="net.urbanguru.wanep.dao.LocaleManager"> <property name="sessionFactory"><ref bean="wanepSessionFactory" /></property> </bean> <bean id="wanepSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> ...CUT... </bean>
Both beans get populated with the LocaleManager at initialise time, but the LocaleInterceptor gets populated with null:Code:<bean id="addCatr" class="net.urbanguru.wanep.web.AddCatController"> <property name="userManager"><ref bean="wanepUserManager" /></property> <property name="localeManager"><ref bean="wanepLocaleManager" /></property> </bean>
whereas the AddCat bean gets populated successfully:Code:2004-09-02 14:52:02,315 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Getting BeanInfo for class [net.urbanguru.wan ep.web.LocaleInterceptor]> 2004-09-02 14:52:02,321 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Caching PropertyDescriptors for class [net.ur banguru.wanep.web.LocaleInterceptor]> 2004-09-02 14:52:02,321 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found property 'class' of type [class java.la ng.Class]; editor=[null]> 2004-09-02 14:52:02,321 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found property 'localeManager' of type [class net.urbanguru.wanep.dao.LocaleManager]; editor=[null]> 2004-09-02 14:52:02,321 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Class [net.urbanguru.wanep.web.LocaleIntercep tor] is cache-safe> 2004-09-02 14:52:02,321 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Resolving reference from prop erty 'localeManager' in bean 'localeInterceptor' to bean 'wanepLocaleManager'> 2004-09-02 14:52:02,321 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Returning cached instance of singleton bean 'wanepLocaleManager'> 2004-09-02 14:52:02,322 DEBUG [org.springframework.beans.BeanWrapperImpl] - <About to invoke write method [public void net.urbanguru. wanep.web.LocaleInterceptor.setLocaleManager(net.urbanguru.wanep.dao.LocaleManager)] on object of class [net.urbanguru.wanep.web.Loca leInterceptor]> net.urbanguru.wanep.web.LocaleInterceptor@8deb8a null 2004-09-02 14:52:02,322 DEBUG [org.springframework.beans.BeanWrapperImpl] - <Invoked write method [public void net.urbanguru.wanep.we b.LocaleInterceptor.setLocaleManager(net.urbanguru.wanep.dao.LocaleManager)] with value of type [net.urbanguru.wanep.dao.LocaleManage r]>
This means that as soon as I send a request to the web app I immediately get a NullPointerException as the LocaleInterceptor tries to access the LocaleManager, which is of course null.Code:2004-09-02 14:52:02,370 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Getting BeanInfo for class [net.urbanguru.wan ep.web.AddCatController]> 2004-09-02 14:52:02,374 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Caching PropertyDescriptors for class [net.ur banguru.wanep.web.AddCatController]> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found property 'catManager' of type [class ne t.urbanguru.wanep.dao.CatManager]; editor=[null]> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found property 'class' of type [class java.la ng.Class]; editor=[null]> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Found property 'localeManager' of type [class net.urbanguru.wanep.dao.LocaleManager]; editor=[null]> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.CachedIntrospectionResults] - <Class [net.urbanguru.wanep.web.AddCatControll er] is cache-safe> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Resolving reference from prop erty 'catManager' in bean 'addCat' to bean 'wanepCatManager'> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Returning cached instance of singleton bean 'wanepCatManager'> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Resolving reference from prop erty 'localeManager' in bean 'addCat' to bean 'wanepLocaleManager'> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - <Returning cached instance of singleton bean 'wanepLocaleManager'> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.BeanWrapperImpl] - <About to invoke write method [public void net.urbanguru. wanep.web.AddCatController.setCatManager(net.urbanguru.wanep.dao.CatManager)] on object of class [net.urbanguru.wanep.web.AddCatContr oller]> 2004-09-02 14:52:02,375 DEBUG [org.springframework.beans.BeanWrapperImpl] - <Invoked write method [public void net.urbanguru.wanep.we b.AddCatController.setCatManager(net.urbanguru.wanep.dao.CatManager)] with value of type [net.urbanguru.wanep.dao.CatManager]> 2004-09-02 14:52:02,376 DEBUG [org.springframework.beans.BeanWrapperImpl] - <About to invoke write method [public void net.urbanguru. wanep.web.AddCatController.setLocaleManager(net.urbanguru.wanep.dao.LocaleManager)] on object of class [net.urbanguru.wanep.web.AddCa tController]> AddCatController: net.urbanguru.wanep.dao.LocaleManager@87d472 2004-09-02 14:52:02,376 DEBUG [org.springframework.beans.BeanWrapperImpl] - <Invoked write method [public void net.urbanguru.wanep.we b.AddCatController.setLocaleManager(net.urbanguru.wanep.dao.LocaleManager)] with value of type [net.urbanguru.wanep.dao.LocaleManager ]>
Does anybody have any idea what's going on? I am going a bit crazy.
This happens with spring 1.0.2 and 1.1 RC2
Thanks in advance,
Jez.


Reply With Quote