The fact that referencing epsg plugins are an exclusive proposition (only one should be on the classpath) keeps tripping up new users and is frankly rude.
Either:
- only ship epsg-hsql in the sample GeoTools download; or
- make the epsg modules non fatal (have them test their platform, and the available DataSource) before being invoked
The following is the origional bug report - when the failure was noted while working with WFSDataStore.
When using GeoTools on a MacOS X platform (affects 2.4.x stream, not 2.3.x), a crash occurs when performing "org.geotools.data.wfs.WFSDataStore.getSchema()".
The bottom line is that the version of Java2 SDK shipped with Mac (built by Apple) does not contain the JDBC-ODBC bridge. This fact can be verified by a large body of documentation available through your nearest search engine.
During factory registry initialization, all plugins are loaded. This happens on the first call to getSchema(). When the epsg-access plugin is loaded, an instance of org.geotools.referencing.factory.epsg.AccessDataSource is created, which is dependent on sun.jdbc.odbc.ee.DataSource. The most assiduous readers will conclude that, on a Mac, this situation will generate an exception. Here is what this exception looks like:
java.lang.NoClassDefFoundError: sun/jdbc/odbc/ee/DataSource
org.geotools.referencing.factory.epsg.FactoryOnAccess.createDataSource(FactoryOnAccess.java:71)
org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore0(ThreadedEpsgFactory.java:384)
org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore(ThreadedEpsgFactory.java:476)
org.geotools.referencing.factory.DeferredAuthorityFactory.getBackingStore(DeferredAuthorityFactory.java:138)
org.geotools.referencing.factory.BufferedAuthorityFactory.isAvailable(BufferedAuthorityFactory.java:232)
org.geotools.referencing.factory.DeferredAuthorityFactory.isAvailable(DeferredAuthorityFactory.java:126)
org.geotools.factory.FactoryRegistry.isAvailable(FactoryRegistry.java:663)
org.geotools.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:491)
org.geotools.factory.FactoryRegistry.getServiceImplementation(FactoryRegistry.java:425)
org.geotools.factory.FactoryRegistry.getServiceProvider(FactoryRegistry.java:354)
org.geotools.factory.FactoryCreator.getServiceProvider(FactoryCreator.java:115)
org.geotools.referencing.ReferencingFactoryFinder.getAuthorityFactory(ReferencingFactoryFinder.java:229)
org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactory(ReferencingFactoryFinder.java:450)
org.geotools.referencing.factory.epsg.LongitudeFirstFactory.createBackingStore(LongitudeFirstFactory.java:188)
org.geotools.referencing.factory.DeferredAuthorityFactory.getBackingStore(DeferredAuthorityFactory.java:138)
org.geotools.referencing.factory.BufferedAuthorityFactory.isAvailable(BufferedAuthorityFactory.java:232)
org.geotools.referencing.factory.DeferredAuthorityFactory.isAvailable(DeferredAuthorityFactory.java:126)
org.geotools.factory.FactoryRegistry.isAvailable(FactoryRegistry.java:663)
org.geotools.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:491)
org.geotools.factory.FactoryRegistry$1.filter(FactoryRegistry.java:168)
javax.imageio.spi.FilterIterator.advance(ServiceRegistry.java:793)
javax.imageio.spi.FilterIterator.<init>(ServiceRegistry.java:787)
javax.imageio.spi.ServiceRegistry.getServiceProviders(ServiceRegistry.java:491)
org.geotools.factory.FactoryRegistry.getServiceProviders(FactoryRegistry.java:175)
org.geotools.referencing.ReferencingFactoryFinder.getFactories(ReferencingFactoryFinder.java:187)
org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactories(ReferencingFactoryFinder.java:465)
org.geotools.referencing.DefaultAuthorityFactory.<init>(DefaultAuthorityFactory.java:57)
org.geotools.referencing.CRS.getAuthorityFactory(CRS.java:188)
org.geotools.referencing.CRS.decode(CRS.java:416)
org.geotools.referencing.CRS.decode(CRS.java:350)
org.geotools.data.wfs.WFSDataStore.getSchema(WFSDataStore.java:405)
ca.carleton.gcrc.nunaliit.server.easyOgc.springmvc.views.WfsFeatureTypeView.printBody(WfsFeatureTypeView.java:46)
ca.carleton.gcrc.nunaliit.server.easyOgc.springmvc.views.AbstractHtmlView.render(AbstractHtmlView.java:35)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1103)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:840)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:754)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:399)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:354)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
A work-around is to delete the file gt2-epsg-access-2.4.jar from the distribution. Obviously, this work around does not apply to those expecting to retrieve EPSG data from access databases on other platforms.
The solution will be to catch said exception somewhere in the stack shown above and disregard it. However, the submitter's confidence on the affected code is not high enough at this point to suggest a patch.
Here is the documentation page:
- http://docs.codehaus.org/display/GEOTDOC/07+Referencing
The information you missed is called "Before you start"; the advice is repeated all over the user guide ... for exampe here:
- http://docs.codehaus.org/display/GEOTDOC/Welcome+to+Eclipse+Developers