From: Paul G. <pau...@gm...> - 2013-04-05 09:08:19
|
Hey Ben, hey List, thanks for the quick reply. That was it. I had a JTS version 1.9 in another project which I related to. The other project included a "static" jts-jar. Upgraded both to 1.12 (which is needed by geotools 8.0), and using maven instead of static includes, thats it. Thank you very much for your hint. Greetings, Paul 2013/4/5 Ben Caradoc-Davies <Ben...@cs...>: > Paul, > > looks like you have an ancient JTS on your classpath, like a 2006 vintage > JTS 1.8 from vividsolutions.com, which has an incompatible ByteArrayInStream > API (setBuffer not the newer setBytes). I can't tell exactly when this API > changed because this it happened before 2010, older than the first revision > of this file in sourceforge subversion. Maven should have automatically > provided you with a newer version compatible with your GeoTools, but is it > possible that something is pulling in another version. What is the result of > "mvn dependency:tree"? You are looking for entries like > "com.vividsolutions:jts:jar:1.13:compile"; you should have only one version > present on your classpath, perhaps 1.11 or 1.12 at the oldest. > > Maven 3 (such as 3.0.5) is pretty good at version-managing conflicts but is > can be misconfigured. If you have a dependency that requires or bundles JTS > 1.8, you have a problem. If it will work with a GeoTools-compatible JTS, > Maven can be configured to exclude the transitive dependency. > > It might not be a Maven problem. How are you bundling and running your > application? Are you inadvertently including an old JTS jar? In your JVM > system library? For web apps, check your tomcat shared libraries. > > Kind regards, > Ben. > > > On 04/04/13 20:11, Paul Goldstein wrote: >> >> Hey List, >> i'm pretty new to geotools but think its a great tool to process >> geodata with java. >> >> I would like to access and process a postgis-database with geotools >> but still got an error: >> >> Exception in thread "main" java.lang.NoSuchMethodError: >> com.vividsolutions.jts.io.ByteArrayInStream.setBytes([B)V >> at >> org.geotools.data.postgis.WKBAttributeIO.wkb2Geometry(WKBAttributeIO.java:81) >> at >> org.geotools.data.postgis.WKBAttributeIO.read(WKBAttributeIO.java:112) >> at >> org.geotools.data.postgis.PostGISDialect.decodeGeometryValue(PostGISDialect.java:195) >> at >> org.geotools.jdbc.JDBCFeatureReader.next(JDBCFeatureReader.java:310) >> at >> org.geotools.jdbc.JDBCFeatureReader.next(JDBCFeatureReader.java:70) >> at >> org.geotools.data.store.ContentFeatureCollection$WrappingFeatureIterator.next(ContentFeatureCollection.java:145) >> at >> org.geotools.data.store.ContentFeatureCollection$WrappingFeatureIterator.next(ContentFeatureCollection.java:125) >> at >> tools.postgisAccess.APostgisAccessTool.<init>(APostgisAccessTool.java:115) >> >> >> This is the code in APostgisAccessTool: >> HashMap<String, Object> params = new HashMap<String, Object>(); >> params.put("dbtype", "postgis"); >> params.put("host", "hostname"); >> params.put("port", new Integer(5432)); >> params.put("database", "database-name"); >> params.put("user", "user"); >> params.put("passwd", "pass"); >> >> String table = "table"; >> String column = "column"; >> >> try { >> DataStore dataStore = DataStoreFinder.getDataStore(params); >> >> SimpleFeatureSource pgSource = >> dataStore.getFeatureSource(table); >> SimpleFeatureCollection featureColl = >> pgSource.getFeatures(CQL.toFilter(column + " is not null")); >> >> int count = >> dataStore.getFeatureSource(table).getCount(Query.ALL); >> >> SimpleFeatureIterator featureIter = featureColl.features(); >> while(featureIter.hasNext()) { >> >> /* #### LINE 115 #### */ >> SimpleFeature feature = featureIter.next(); >> } >> >> } catch (IOException | CQLException e) { >> e.printStackTrace(); >> } >> >> >> As you can see, the exception throws when getting the next feature >> from the iterator (below comment). >> I reduced my database, as there is only one row with one point >> geometry which is in epsg 4326. Count gives me the correct result ( 1 >> ). >> I'm using a Postgres 9.1 database with 9.1-901.jdbc4 connector. >> I first used geotools 8.0 (stable) and tried it with an upgraded >> version 9.0. Neither of both worked. >> >> I also tried to switch bytea_output set to "escape" instead of "hex". >> Nothing changed. >> >> Does anybody knows a solution or have an hint how to solve this >> problem? - Thanks. >> >> Greetings, >> paul. >> > > -- > Ben Caradoc-Davies <Ben...@cs...> > Software Engineer > CSIRO Earth Science and Resource Engineering > Australian Resources Research Centre |