Search code examples
gwtjettygeotoolsgwt-hosted-mode

GeoTools with GWT (Development Mode Jetty)


Using GeoTools with GWT, I get the following stack trace when running my app in Development Mode:

WARNING: Can't load a service for category "CRSAuthorityFactory". Cause is "ServiceConfigurationError: org.opengis.referencing.crs.CRSAuthorityFactory: Provider org (...) lang.ClassCastException: class org.geotools.referencing.operation.DefaultMathTransformFactory".
sun.misc.ServiceConfigurationError: org.opengis.referencing.crs.CRSAuthorityFactory: Provider org.geotools.referencing.factory.epsg.DefaultFactory could not be instantiated: java.lang.ClassCastException: class org.geotools.referencing.operation.DefaultMathTransformFactory
    at sun.misc.Service.fail(Unknown Source)
    at sun.misc.Service.access$200(Unknown Source)
    at sun.misc.Service$LazyIterator.next(Unknown Source)
    at org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:829)
    at org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:773)
    at org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:808)
    at org.geotools.factory.FactoryRegistry.getUnfilteredProviders(FactoryRegistry.java:229)
    at org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:429)
    at org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:364)
    at org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:143)
    at org.geotools.referencing.ReferencingFactoryFinder.getAuthorityFactory(ReferencingFactoryFinder.java:216)
    at org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactory(ReferencingFactoryFinder.java:436)

This seems to be a Jetty thing, because it works fine when I deploy to another container. Any ideas on how to fix this?


Solution

  • It looks like it's a problem with class-loading in Jetty. Found this GeoTools issue, and this GWT patch, both of which seem to address the problem, but neither of which seem to be getting attention at the moment. GeoMajas solves the problem with a ServletFilter to hijack Jetty's classloader: I ended up taking the same approach, which worked.