2

I am trying to load and parse a shapefile using the GeoTools library. However, when I try to load the file the following call is resulting is a dependency failure for org.geotools.factory.FactoryRegistry:

DataStore newStore = DataStoreFinder.getDataStore(connect);

Error:

org/geotools/factory/FactoryRegistry
java.lang.NoClassDefFoundError: org/geotools/factory/FactoryRegistry

I have included the following dependencies in gradle:

compile files ('libs/geotools/gt-opengis-14.2.jar')
compile files ('libs/geotools/gt-api-14.2.jar')
compile files ('libs/geotools/gt-shapefile-14.2.jar')
compile files ('libs/geotools/gt-cql-14.2.jar')
compile files ('libs/geotools/gt-main-14.2.jar')
compile files ('libs/geotools/gt-referencing-14.2.jar')
compile files ('libs/geotools/gt-epsg-hsql-14.2.jar')

I am not sure if all of them are needed but none of them have the missing class. Is there any other dependency I am missing? The class is documented here.

341008
  • 9,862
  • 11
  • 52
  • 84

1 Answers1

1

The easy answer to this problem is to use Maven to manage your dependencies, this would then automatically pull in gt-metadata for you and solve your problem.

If you must manage your dependencies by hand then the I wrote a blog post that describes how to use oops to search the GeoTools jars for a class.

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • Thanks. I added `gt-metadata`. That solved this problem but now I am getting other similar errors for other classes. I know using Maven (or Gradle) to manage dependencies would solve this. But these dependencies are not found in the repo. I have seen other people report the same problem but none of the solutions proposed work for me. – 341008 Mar 18 '16 at 17:53
  • What sort of store are you trying to connect to? – Ian Turton Mar 18 '16 at 17:56
  • Tried quite a few. Latest one is http://download.osgeo.org/webdav/geotools/. But that seems to be inconsistent. Different dependencies are reported missing at different times. Right now the missing one is `Could not find jai_core.jar (javax.media:jai_core:1.1.3)`. – 341008 Mar 19 '16 at 04:04
  • Fixed. Gradle was looking for `jai_core` from `mavenCentral`. Moving `mavenCentral` after `osgeo` in repository list fixed it. – 341008 Mar 19 '16 at 05:45