
Originally Posted by
Marten Deinum
In general you shouldn't be doing something like this you can end up with multiple instances of the singleton (try deserializing and serializing a singleton and you will have 2 instances).
In general you want to use a lazy proxy of some kind to retrieve/use the singleton from the context.
Hi Marten,
I changed my config to this:
Code:
<bean id="mainService" class="com.jeanbaptistemartin.service.MainServiceImpl" lazy-init="true"/>
<bean id="service" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="targetSource">
<bean class="org.springframework.aop.target.LazyInitTargetSource">
<property name="targetBeanName">
<idref local="mainService" />
</property>
</bean>
</property>
</bean>
Code:
private transient MainService mainService;
public SuggestionOeuvreView() {
log.debug("SuggestionOeuvreView()");
}
@Autowired
public SuggestionOeuvreView(MainService mainService) {
log.debug("SuggestionOeuvreView(MainService mainService)");
this.mainService = mainService;
this.sculpturesNonVisitees = recupererSculpturesNonVisitees();
}
I still get the same NPE...
Any other idea?
J.