Hello!
We are using GeoServer as a part of web application (several GeoServer's
modules: data, platform, main, ows,..). It serves as an engine to
load/persist features directly from/to their datastores and lets us to reuse
rich configuration of datastores and feature types in XML, gives direct
access to features without WFS XML request/response expenses and so on. But
the web application relies on the Spring 2.5 which is more strict then
1.2.x.
Basic configuration of GeoServer beans looks like:
======================================================
<!-- GeoServer configuration -->
<!-- resources -->
<bean id="resourceLoader"
class="org.geoserver.platform.GeoServerResourceLoader" />
<!-- configuration module -->
<bean id="config" class="org.vfny.geoserver.global.Config" />
<!-- geoserver module -->
<bean id="geoServer" class="org.vfny.geoserver.global.GeoServer">
<constructor-arg ref="config" />
</bean>
<bean id="globalConfig"
class="org.vfny.geoserver.config.GlobalConfig">
<constructor-arg ref="geoServer" />
</bean>
<!-- data module -->
<bean id="data" class="org.vfny.geoserver.global.Data">
<constructor-arg ref="config" />
<constructor-arg ref="geoServer" />
</bean>
<alias name="data" alias="catalog" />
<bean id="dataConfig" class="org.vfny.geoserver.config.DataConfig">
<constructor-arg ref="data" />
</bean>
=================================================
WebApplictionContext.refresh() method fails during starting of the Spring
container because it calls ApplicationContext.destroy() methods of classes
that implement DisplosableBean interface like
org,vfny.geoserver.global.GeoServer class. destroy() method of the last one
tries to get a bean during destroying Spring container during refreshing
process, it causes an exception with Spring 2.5:
============================================================
19:34:16 ERROR [support.DisposableBeanAdapter] - Couldn't invoke destroy
method of bean with name 'geoServer'
org.springframework.beans.factory.BeanCreationNotAllowedException: Error
creating bean with name 'data': Singleton bean creation not allowed while
the singletons of this factory are in destruction (Do not request a bean
from a BeanFactory in a destroy method implementation!)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSi
ngleton(DefaultSingletonBeanRegistry.java:156)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:248)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:170)
at
org.springframework.context.support.AbstractApplicationContext.getBean(Abstr
actApplicationContext.java:883)
at org.vfny.geoserver.global.GeoServer.destroy(GeoServer.java:1033)
at
org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(Disp
osableBeanAdapter.java:154)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destr
oyBean(DefaultSingletonBeanRegistry.java:397)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destr
oySingleton(DefaultSingletonBeanRegistry.java:375)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destr
oySingletons(DefaultSingletonBeanRegistry.java:348)
at
org.springframework.context.support.AbstractApplicationContext.refresh(Abstr
actApplicationContext.java:377)
=====================================================================
The idea is to make GeoServer bean aware about Data by a local reference to
its instance or implement DisposableBean interface in Data class itself and
move functionality from GeoServer.destroy() to Data.destroy().
I have just started to test GeoServer 1.6.x with Spring 2.5 in the context
of our webapp architecture, may be there are other places that would be
desirable to make compatible with Spring 1.2.x and Spring 2.5.
Vitali Diatchkov.