neo4j-contrib / spatial

Neo4j Spatial is a library of utilities for Neo4j that faciliates the enabling of spatial operations on data. In particular you can add spatial indexes to already located data, and perform spatial operations on the data like searching for data within specified regions or within a specified distance of a point of interest. In addition classes are provided to expose the data to geotools and thereby to geotools enabled applications like geoserver and uDig.
http://neo4j-contrib.github.io/spatial
Other
781 stars 192 forks source link

Export shapefile throw java.lang.NoClassDefFoundError: org/apache/log4j/Logger #210

Open jpopol opened 9 years ago

jpopol commented 9 years ago

Hi I have integrated a point graph in neo4j but when I want to export those point as a shapefile I receive the following exception and the generated file is empty of data content.

Is it something you guys already experienced ?

Nov 20, 2015 3:04:45 PM org.geotools.data.shapefile.ShapefileDataStore createSchema WARNING: PRJ file not generated for null CoordinateReferenceSystem getFeatureSource(SeaGraph) - locking manager is present getFeatureReader(SeaGraph,class org.opengis.filter.IncludeFilter Filter.INCLUDE) java.lang.NoClassDefFoundError: org/apache/log4j/Logger at org.geotools.data.neo4j.Neo4jSpatialFeatureReader.(Neo4jSpatialFeatureReader.java:43) at org.geotools.data.neo4j.Neo4jSpatialDataStore.getFeatureReader(Neo4jSpatialDataStore.java:335) at org.geotools.data.neo4j.Neo4jSpatialDataStore.getFeatureReader(Neo4jSpatialDataStore.java:305) at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:369) at org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:215) at org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:231) at org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:199) at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:188) at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:79) at org.geotools.data.store.ContentFeatureStore.addFeatures(ContentFeatureStore.java:243) at org.neo4j.gis.spatial.ShapefileExporter.exportLayer(ShapefileExporter.java:91) at org.neo4j.gis.spatial.ShapefileExporter.exportLayer(ShapefileExporter.java:57)

craigtaverner commented 9 years ago

Is it possible for you to provide some code that causes this problem?

Looking at the error I see two things that might be relevant. One is that you have not specified a coordinate reference system, the other is that you have not configured log4j. It is not for certain that either of these are the reason the file is empty, but they could be relevant.

Best that you create a failing test case for us to review On Nov 20, 2015 5:01 PM, "jpopol" notifications@github.com wrote:

Hi I have integrated a point graph in neo4j but when I want to export those point as a shapefile I receive the following exception and the generated file is empty of data content.

Is it something you guys already experienced ?

Nov 20, 2015 3:04:45 PM org.geotools.data.shapefile.ShapefileDataStore createSchema WARNING: PRJ file not generated for null CoordinateReferenceSystem getFeatureSource(SeaGraph) - locking manager is present getFeatureReader(SeaGraph,class org.opengis.filter.IncludeFilter Filter.INCLUDE) java.lang.NoClassDefFoundError: org/apache/log4j/Logger at org.geotools.data.neo4j.Neo4jSpatialFeatureReader.(Neo4jSpatialFeatureReader.java:43) at org.geotools.data.neo4j.Neo4jSpatialDataStore.getFeatureReader(Neo4jSpatialDataStore.java:335) at org.geotools.data.neo4j.Neo4jSpatialDataStore.getFeatureReader(Neo4jSpatialDataStore.java:305) at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:369) at org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:215) at org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:231) at org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:199) at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:188) at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:79) at org.geotools.data.store.ContentFeatureStore.addFeatures(ContentFeatureStore.java:243) at org.neo4j.gis.spatial.ShapefileExporter.exportLayer(ShapefileExporter.java:91) at org.neo4j.gis.spatial.ShapefileExporter.exportLayer(ShapefileExporter.java:57)

— Reply to this email directly or view it on GitHub https://github.com/neo4j-contrib/spatial/issues/210.

jpopol commented 9 years ago

I don't have the code right now with me but I'm pretty sure that I don't specify the coordinate reference system. I'll give a sample of the code tomorrow

2015-11-22 11:47 GMT+00:00 Craig Taverner notifications@github.com:

Is it possible for you to provide some code that causes this problem?

Looking at the error I see two things that might be relevant. One is that you have not specified a coordinate reference system, the other is that you have not configured log4j. It is not for certain that either of these are the reason the file is empty, but they could be relevant.

Best that you create a failing test case for us to review On Nov 20, 2015 5:01 PM, "jpopol" notifications@github.com wrote:

Hi I have integrated a point graph in neo4j but when I want to export those point as a shapefile I receive the following exception and the generated file is empty of data content.

Is it something you guys already experienced ?

Nov 20, 2015 3:04:45 PM org.geotools.data.shapefile.ShapefileDataStore createSchema WARNING: PRJ file not generated for null CoordinateReferenceSystem getFeatureSource(SeaGraph) - locking manager is present getFeatureReader(SeaGraph,class org.opengis.filter.IncludeFilter Filter.INCLUDE) java.lang.NoClassDefFoundError: org/apache/log4j/Logger at

org.geotools.data.neo4j.Neo4jSpatialFeatureReader.(Neo4jSpatialFeatureReader.java:43) at

org.geotools.data.neo4j.Neo4jSpatialDataStore.getFeatureReader(Neo4jSpatialDataStore.java:335) at

org.geotools.data.neo4j.Neo4jSpatialDataStore.getFeatureReader(Neo4jSpatialDataStore.java:305) at

org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:369) at

org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:215) at

org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:231) at

org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:199) at

org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:188) at

org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:79) at

org.geotools.data.store.ContentFeatureStore.addFeatures(ContentFeatureStore.java:243) at

org.neo4j.gis.spatial.ShapefileExporter.exportLayer(ShapefileExporter.java:91) at

org.neo4j.gis.spatial.ShapefileExporter.exportLayer(ShapefileExporter.java:57)

— Reply to this email directly or view it on GitHub https://github.com/neo4j-contrib/spatial/issues/210.

— Reply to this email directly or view it on GitHub https://github.com/neo4j-contrib/spatial/issues/210#issuecomment-158752266 .

jpopol commented 9 years ago

code sample I hope you don't mind scala, if there is any doubt about meanings let me know

val tx = db.beginTx()
val spatialService = new SpatialDatabaseService(db)
val layer = spatialService.getOrCreateLayer("SeaGraph", classOf[WKBGeometryEncoder], classOf[EditableLayerImpl]).asInstanceOf[EditableLayer]
val geometryFactory = layer.getGeometryFactory

// Then for each node we have in another graph representation
val point = geometryFactory.createPoint(new Coordinate(nodeFromOtherLib.getAttribute[Double]("x"), nodeFromOtherLib.getAttribute[Double]("y")))

val geoNode = layer.add(point)
val neoNode = geoNode.getGeomNode

neoNode.addLabel(locationLabel)
neoNode.setProperty("name", nodeFromOtherLib.getId)

tx.success()
tx.close()

finally:

//db is GraphDatabaseService 
// layer is "SeaGraph"
 new ShapefileExporter(db).exportLayer(layer, file) //<- this is the code that fail for me
jpopol commented 9 years ago

Okay so I made an other test where I integrate the CRS

//...
val layer = spatialService.getOrCreateLayer("SeaGraph", classOf[WKBGeometryEncoder], classOf[EditableLayerImpl]).asInstanceOf[EditableLayer]
layer.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84)
//...

and I still end up with this problem meaning that this issue lean toward log4j config I guess

jpopol commented 9 years ago

Okay I think I fount it I had to add this dependency in my build:

"org.apache.logging.log4j" % "log4j-api" % "2.3"
ehx-v1 commented 8 years ago

if this is solved, why is it still open then?

jpopol commented 8 years ago

Well I proposed a workaround which is basically bringing some necessary dependencies that are not shipped out of the box. But I believe the real issue (missing dependencies) is still present right ?

ehx-v1 commented 8 years ago

that should be in the Apache Commons if I'm not mistaken, which should be pulled by Neo4j, perhaps you should check your Maven

ehx-v1 commented 8 years ago

now I have similar issues with org.apache.commons.collections.MapUtils obviously Apache has done some Commons restructuring without any notice @craigtaverner please update the dependencies, and you should request Apache to have a proper notificational changelog

ehx-v1 commented 8 years ago

after adding the dependency it still doesn't work because the package is (...).collections4.MapUtils instead of collections

ehx-v1 commented 8 years ago

ok with lots of help from Google ;-) I found this dependency, which keeps fitting: https://1maven.com/findpomandjar/org.glassfish.external:apache-commons:3.0-b68

ehx-v1 commented 8 years ago

that's what you should pull

ehx-v1 commented 8 years ago

in this dependency there's also such thing as logging/Log, which you perhaps could consider switching to