spatial icon indicating copy to clipboard operation
spatial copied to clipboard

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

Open jpopol opened this issue 9 years ago • 13 comments

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)

jpopol avatar Nov 20 '15 16:11 jpopol

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" [email protected] 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.

craigtaverner avatar Nov 22 '15 11:11 craigtaverner

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 [email protected]:

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" [email protected] 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 avatar Nov 22 '15 13:11 jpopol

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 avatar Nov 23 '15 10:11 jpopol

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 avatar Nov 23 '15 13:11 jpopol

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

"org.apache.logging.log4j" % "log4j-api" % "2.3"

jpopol avatar Nov 23 '15 14:11 jpopol

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

ehx-v1 avatar Mar 30 '16 10:03 ehx-v1

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 ?

jpopol avatar Mar 30 '16 11:03 jpopol

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 avatar Apr 01 '16 19:04 ehx-v1

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 avatar Apr 04 '16 08:04 ehx-v1

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

ehx-v1 avatar Apr 04 '16 10:04 ehx-v1

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 avatar Apr 04 '16 10:04 ehx-v1

that's what you should pull

ehx-v1 avatar Apr 04 '16 10:04 ehx-v1

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

ehx-v1 avatar Apr 04 '16 11:04 ehx-v1