[Geoserver-devel] wcs111 test broken due to GeoServerFactoryIterator

Hi,
today after updating GeoServer I discovered the wcs111 unit tests were not working anymore. I was quite baffled at first, especially because
the stack trace (attached) it's long, but I think I figured out
what's going on.

In my configuration, things happen in this order:
* the Config object is loaded, this triggers the creation of
   an XmlReader (and here we enter in the xml reader constructor)
* the xml reader constructor tries to load the catalog and config
   files. At a certain point a coverage is read, and this requires
   some wkt parsing, so CRS.parseWKT is called
* the referencing subsystem engages, and starts looking for
   authorities in the SPI. The GeoServerFactoryIteratorProvider
   has already been created and the SPI tries to use it to
   find CRS authorities. The iterator calls GeoServerExtensions
* GeoServerExtension looks into the the spring context (whose
   initialization is not complete) and apparently this results
   in the wcs 111 service object being created. But this
   requires the catalog, which in turn requires geoserver and...
* when GeoServer object is created, it assumes it's safe
   to call config.getGeoserver() which in turns calls
   reader.getGeoServer(), but the above reader is still not
   assigned because it's still being created -> kaboom, NPE!

Now, the GeoServerFactoryIteratorProvider has been around
since November, but it has been registered only yesterday
by a Justin's commit.

I tried to poke at it but it seems no matter what I do
I end up creating a circular dependency.
Basically what I tried is to alter the following spring
definition:

<!-- extensions -->
  <bean id="extensions" class="org.geoserver.platform.GeoServerExtensions" />
  
  <!-- geotools factory iterator provider -->
  <bean id="factoryIteratorProvider" depends-on="extensions"
     class="org.geoserver.platform.GeoServerFactoryIteratorProvider"/>

so that either the iterator or the extensions depend on config
but I only get circular dependencies. What I was trying to do is
to ensure config is created before the iterator is created in
order to avoid the above problem... but I end up creating
another. I'll keep on working on this one trying to solve it,
but if you have any idea I'll all ears :slight_smile:

Cheers
Andrea

(attachments)

stacktrace.txt (30.1 KB)

Andrea Aime ha scritto:

<!-- extensions -->
    <bean id="extensions" class="org.geoserver.platform.GeoServerExtensions" />
        <!-- geotools factory iterator provider -->
    <bean id="factoryIteratorProvider" depends-on="extensions"
       class="org.geoserver.platform.GeoServerFactoryIteratorProvider"/>

Ah, I did not notice that now:

  <bean id="config"
    class="org.vfny.geoserver.global.Config" depends-on="factoryIteratorProvider"/>

so I guess Justin needs it. But it breaks WCS tests, and I've
just noticed it breaks startup with release configuration
as well (same issue, release configuration has coverages around).

So if you see this problem and want to keep on working, remove
the depends-on="factoryIteratorProvider" declaration from
applicationContext.xml in the main module. Or provide a real solution
(I can't see any at the moment).

Cheers
Andrea

Feel free to disable this for now if you want Andrea. I just need it for
H2 datastore to be registered in GEoServer. I will look into this issue
deeper to see what is going on.

-Justin

Andrea Aime wrote:

Andrea Aime ha scritto:

<!-- extensions -->
    <bean id="extensions"
class="org.geoserver.platform.GeoServerExtensions" />
        <!-- geotools factory iterator provider -->
    <bean id="factoryIteratorProvider" depends-on="extensions"
       class="org.geoserver.platform.GeoServerFactoryIteratorProvider"/>

Ah, I did not notice that now:

    <bean id="config"
        class="org.vfny.geoserver.global.Config"
depends-on="factoryIteratorProvider"/>

so I guess Justin needs it. But it breaks WCS tests, and I've
just noticed it breaks startup with release configuration
as well (same issue, release configuration has coverages around).

So if you see this problem and want to keep on working, remove
the depends-on="factoryIteratorProvider" declaration from
applicationContext.xml in the main module. Or provide a real solution
(I can't see any at the moment).

Cheers
Andrea

!DSPAM:4007,477e724c108411096210785!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org

Justin Deoliveira ha scritto:

Feel free to disable this for now if you want Andrea. I just need it for
H2 datastore to be registered in GEoServer. I will look into this issue
deeper to see what is going on.

Ok. For the record, the full workaround is to:
* comment out the declaration of the iterator in the main module application context
* remove the depends-on from config bean in the same file.

Cheers
Andrea