I wrote some java code using geotools library using the maven build tool. This small code runs successfully when i run it as an independent java application in the maven project . But since i needed to use this piece of code in another project where i do not have maven , i copied all the jar files from the Maven Dependencies folder in the maven project to my other project and added these as external jars/dependencies.But this piece of code does not run in the new project when i run it as a java application in eclipse.Here is the piece of code and the stacktrace.:
38. public static void main(String[] args) throws Exception {
39. File file = new File("path to shapefile");
40. modifyShapeFile(file);
...........................................
............................
}
52. public static void modifyShapeFile(final File file) throws Exception {
53. ShapefileDataStore store = (ShapefileDataStore) FileDataStoreFinder
.getDataStore(file);
54. SimpleFeatureSource featureSource = store.getFeatureSource();
55. SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
56. Transaction transaction = new DefaultTransaction("modify");
57. featureStore.setTransaction(transaction);
58. SimpleFeatureType featureType = store.getSchema();
59. SimpleFeatureBuilder build = new SimpleFeatureBuilder(featureType);
........................................................
.........................................................
StackTrace:
Exception in thread "main" java.lang.NoSuchFieldError: METER
at org.geotools.referencing.wkt.Parser.parseSpheroid(Parser.java:560)
at org.geotools.referencing.wkt.Parser.parseDatum(Parser.java:656)
at org.geotools.referencing.wkt.Parser.parseGeoGCS(Parser.java:867)
at org.geotools.referencing.wkt.Parser.parseProjCS(Parser.java:913)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:225)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:204)
at org.geotools.referencing.factory.ReferencingObjectFactory.createFromWKT(ReferencingObjectFactory.java:1090)
at org.geotools.data.PrjFileReader.<init>(PrjFileReader.java:94)
at org.geotools.data.PrjFileReader.<init>(PrjFileReader.java:68)
at org.geotools.data.shapefile.ShapefileSetManager.openPrjReader(ShapefileSetManager.java:106)
at org.geotools.data.shapefile.ShapefileFeatureSource.readAttributes(ShapefileFeatureSource.java:515)
at org.geotools.data.shapefile.ShapefileFeatureSource.buildFeatureType(ShapefileFeatureSource.java:471)
at org.geotools.data.shapefile.ShapefileFeatureStore.buildFeatureType(ShapefileFeatureStore.java:131)
at org.geotools.data.store.ContentFeatureSource.getAbsoluteSchema(ContentFeatureSource.java:340)
at org.geotools.data.store.ContentFeatureSource.getSchema(ContentFeatureSource.java:309)
at org.geotools.data.store.ContentDataStore.getSchema(ContentDataStore.java:339)
at org.geotools.data.store.ContentDataStore.getSchema(ContentDataStore.java:712)
at org.geotools.data.shapefile.ShapefileDataStore.getSchema(ShapefileDataStore.java:197)
at com.amazon.marketplacevolumeviewer.shapefile.ModifyShapeFile.modifyShapeFile(ModifyShapeFile.java:58)
at com.amazon.marketplacevolumeviewer.shapefile.ModifyShapeFile.main(ModifyShapeFile.java:40)
The pom.xml file for the maven project is according to this tutorial: http://docs.geotools.org/latest/userguide/tutorial/quickstart/eclipse.html.
There is no source code attaches with these jar files , hence i could not follow the stack trace .