Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 3.00, 3.01
-
Fix Version/s: 3.02
-
Component/s: Referencing
-
Labels:
Description
Having GeoTools and Geotoolkit.org together on the classpath cause recursive method calls until StackTraceOverflow. The stack trace shows a mix of org.geotools and org.geotoolkit packages, as in the example below:
at org.geotoolkit.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:605) at org.geotools.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:572) at org.geotoolkit.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:605) at org.geotoolkit.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:605) at org.geotools.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:572)
This is caused by the CRSFactory being found dynamically at runtime, rather than being statically referenced at compile-time. More specifically both GeoTools ans Geotk define a DatumFactory (the one which manage aliases) looking for an other DatumFactory (the one which know nothing about aliases), both of them having speclal check for avoiding infinite loop with themself, but none of them prepared to live with an other implementation applying the same strategy.
We could make the above-cited "special check" more sophesticated in Geotk, but it would not prevent a similar problem to occur in GeoTools unless the GeoTools code is also patched in the same way. A better approach may be to prevent the implementations to be mixed up at the FactoryFinder level, which actually is already possible. Both Geotk and GeoTools have a FactoryFinder.setVendorOrdering(...) method:
So Geotk should call at some point:
FactoryFinder.setVendorOrdering("Geotoolkit.org", "GeoTools");
while GeoTools may want to do the same method call with the arguments in reverse order. It should be suffisient for preventing random mixes. This JIRA issue is mostly about adding the above-method call in some initialization point and make sure that it works.

Fix tested with a "pseudo-GeoTools DatumFactory implementation", which is part of the test suite for avoiding regression. Not tested with a real GeoTools implementation however...