PDA

View Full Version : BeanWrapperImpl sets one of my bean's properties to null



jazzyjez
Sep 2nd, 2004, 10:01 AM
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:


<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.LocalSessionFact oryBean">
...CUT...
</bean>


There is another bean which has a dependency on LocaleManager:


<bean id="addCatr" class="net.urbanguru.wanep.web.AddCatController">
<property name="userManager"><ref bean="wanepUserManager" /></property>
<property name="localeManager"><ref bean="wanepLocaleManager" /></property>
</bean>


Both beans get populated with the LocaleManager at initialise time, but the LocaleInterceptor gets populated with null:



2004-09-02 14&#58;52&#58;02,315 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Getting BeanInfo for class &#91;net.urbanguru.wan
ep.web.LocaleInterceptor&#93;>
2004-09-02 14&#58;52&#58;02,321 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Caching PropertyDescriptors for class &#91;net.ur
banguru.wanep.web.LocaleInterceptor&#93;>
2004-09-02 14&#58;52&#58;02,321 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Found property 'class' of type &#91;class java.la
ng.Class&#93;; editor=&#91;null&#93;>
2004-09-02 14&#58;52&#58;02,321 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Found property 'localeManager' of type &#91;class
net.urbanguru.wanep.dao.LocaleManager&#93;; editor=&#91;null&#93;>
2004-09-02 14&#58;52&#58;02,321 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Class &#91;net.urbanguru.wanep.web.LocaleIntercep
tor&#93; is cache-safe>
2004-09-02 14&#58;52&#58;02,321 DEBUG &#91;org.springframework.beans.factory.support.Default ListableBeanFactory&#93; - <Resolving reference from prop
erty 'localeManager' in bean 'localeInterceptor' to bean 'wanepLocaleManager'>
2004-09-02 14&#58;52&#58;02,321 DEBUG &#91;org.springframework.beans.factory.support.Default ListableBeanFactory&#93; - <Returning cached instance of
singleton bean 'wanepLocaleManager'>
2004-09-02 14&#58;52&#58;02,322 DEBUG &#91;org.springframework.beans.BeanWrapperImpl&#93; - <About to invoke write method &#91;public void net.urbanguru.
wanep.web.LocaleInterceptor.setLocaleManager&#40;net.u rbanguru.wanep.dao.LocaleManager&#41;&#93; on object of class &#91;net.urbanguru.wanep.web.Loca
leInterceptor&#93;>
net.urbanguru.wanep.web.LocaleInterceptor@8deb8a
null
2004-09-02 14&#58;52&#58;02,322 DEBUG &#91;org.springframework.beans.BeanWrapperImpl&#93; - <Invoked write method &#91;public void net.urbanguru.wanep.we
b.LocaleInterceptor.setLocaleManager&#40;net.urbanguru .wanep.dao.LocaleManager&#41;&#93; with value of type &#91;net.urbanguru.wanep.dao.LocaleManage
r&#93;>


whereas the AddCat bean gets populated successfully:



2004-09-02 14&#58;52&#58;02,370 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Getting BeanInfo for class &#91;net.urbanguru.wan
ep.web.AddCatController&#93;>
2004-09-02 14&#58;52&#58;02,374 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Caching PropertyDescriptors for class &#91;net.ur
banguru.wanep.web.AddCatController&#93;>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Found property 'catManager' of type &#91;class ne
t.urbanguru.wanep.dao.CatManager&#93;; editor=&#91;null&#93;>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Found property 'class' of type &#91;class java.la
ng.Class&#93;; editor=&#91;null&#93;>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Found property 'localeManager' of type &#91;class
net.urbanguru.wanep.dao.LocaleManager&#93;; editor=&#91;null&#93;>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.CachedIntrospectionResu lts&#93; - <Class &#91;net.urbanguru.wanep.web.AddCatControll
er&#93; is cache-safe>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.factory.support.Default ListableBeanFactory&#93; - <Resolving reference from prop
erty 'catManager' in bean 'addCat' to bean 'wanepCatManager'>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.factory.support.Default ListableBeanFactory&#93; - <Returning cached instance of
singleton bean 'wanepCatManager'>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.factory.support.Default ListableBeanFactory&#93; - <Resolving reference from prop
erty 'localeManager' in bean 'addCat' to bean 'wanepLocaleManager'>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.factory.support.Default ListableBeanFactory&#93; - <Returning cached instance of
singleton bean 'wanepLocaleManager'>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.BeanWrapperImpl&#93; - <About to invoke write method &#91;public void net.urbanguru.
wanep.web.AddCatController.setCatManager&#40;net.urban guru.wanep.dao.CatManager&#41;&#93; on object of class &#91;net.urbanguru.wanep.web.AddCatContr
oller&#93;>
2004-09-02 14&#58;52&#58;02,375 DEBUG &#91;org.springframework.beans.BeanWrapperImpl&#93; - <Invoked write method &#91;public void net.urbanguru.wanep.we
b.AddCatController.setCatManager&#40;net.urbanguru.wan ep.dao.CatManager&#41;&#93; with value of type &#91;net.urbanguru.wanep.dao.CatManager&#93;>
2004-09-02 14&#58;52&#58;02,376 DEBUG &#91;org.springframework.beans.BeanWrapperImpl&#93; - <About to invoke write method &#91;public void net.urbanguru.
wanep.web.AddCatController.setLocaleManager&#40;net.ur banguru.wanep.dao.LocaleManager&#41;&#93; on object of class &#91;net.urbanguru.wanep.web.AddCa
tController&#93;>
AddCatController&#58; net.urbanguru.wanep.dao.LocaleManager@87d472
2004-09-02 14&#58;52&#58;02,376 DEBUG &#91;org.springframework.beans.BeanWrapperImpl&#93; - <Invoked write method &#91;public void net.urbanguru.wanep.we
b.AddCatController.setLocaleManager&#40;net.urbanguru. wanep.dao.LocaleManager&#41;&#93; with value of type &#91;net.urbanguru.wanep.dao.LocaleManager
&#93;>


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.

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.

Colin Sampaleanu
Sep 2nd, 2004, 02:39 PM
Jez,

This is a pretty simple case, and there's absolutely no way this should be happening, unless some information is missing here... Unfortuantely I can't suggest what could be going on. If you can isolate it to a test case or some program you can send me, I can try to take a look at that.