The issue is resolved when I closed a FeatureIterator that I had not been 
previously. Thanks very much for the hint Jody. (I will also look into whether 
using a Registry would be better.)

It could well be that there are no streams being left open when the shouldn’t 
be ☺. I only started to wade through the Java source of GeoTools, so I have not 
done a detailed analysis.

When I was not disposing of MapContents or Layers I got a severe warning at 
runtime. This lead me to close them properly. I wonder if something similar 
could happen with FeatureIterators…

I’m still hoping that one day I’ll be able to help out with GeoTools 
development, but at least I’m getting the hang of Maven finally and getting to 
grips with GeoTools more as a user.

Best wishes,

Andy
From: Jody Garnett [mailto:jody.garn...@gmail.com]
Sent: 02 December 2014 23:35
To: Andy Turner
Cc: geotools-devel@lists.sourceforge.net
Subject: Re: [Geotools-devel] Getting to grips with the GeoTools source java 
files for checking/debugging and a potential resource issue to do with streams

Sounds like you are on the right tract - not closing streams is a common issue 
both in using GeoTools (and in writing GeoTools - although we try and stay on 
top of that!).

If you could proceed with your debug hunt we would be keen to hear where 
streams are being left open.

I assume you are closing any iterators you use by hand, and disposing of maps 
and datastore correctly? Are you managing DataStores yourself or making use of 
a Registry?
--
Jody

Jody Garnett

On Tue, Dec 2, 2014 at 2:32 AM, Andy Turner 
<a.g.d.tur...@leeds.ac.uk<mailto:a.g.d.tur...@leeds.ac.uk>> wrote:
Hi geotools-devel,

Apologies if I should be posting this elsewhere.

I am hitting an error/exception when running a program that writes and reads a 
reasonably large number (hundreds) of shapefiles.

The error message is:

WARNING: Could not aquire ESRI(tm) Shapefiles 
(*.shp):java.lang.NullPointerException
java.lang.NullPointerException
        at 
org.geotools.data.shapefile.files.ShpFiles.findExistingFile(ShpFiles.java:210)
        at org.geotools.data.shapefile.files.ShpFiles.init(ShpFiles.java:183)
        at org.geotools.data.shapefile.files.ShpFiles.<init>(ShpFiles.java:139)
        at 
org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:184)
        at 
org.geotools.data.shapefile.ShapefileDataStoreFactory.createDataStore(ShapefileDataStoreFactory.java:303)
        at 
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:95)
        at 
org.geotools.data.FileDataStoreFinder.getDataStore(FileDataStoreFinder.java:69)

I am using GeoTools 12.1, Maven and Netbeans.

The program will get past the part where this error is thrown if I read/write 
fewer shapefiles previously. (And so as a work around I can split up my 
processing into smaller bits and run these to get the output I want, but that 
is not ideal.)

I think the problem is something to do with streams perhaps not being finalised 
and closed and that the program is running out of handles of some stripe.

I have thought to check the GeoTools source file logic for closing all the 
streams in shapefile writing. To do this I have created a fork of GeoTools in 
GitHub and built things locally with Maven so that I have a copy of the 
GeoTools source java files.

I am thinking also to set up a new testing project in Netbeans so I can debug 
the program by going into the GeoTools source files. Maybe it is sensible to do 
this all in one Netbeans project...

BTW, I add the data from each shapefile into its own Layer which is added to a 
MapContent. After I have the image I want I then predispose and dispose of each 
Layer and dispose of the MapContent.

So that is where I am with this, I just thought I post this message before I 
went any further in case anyone has time to give me some advice.

What I have discovered might be a known issue and I expect there is a issue 
tracker that I could look at to know, but I am a bit unsure of where the right 
place to look is.

Anyway, thanks for GeoTools.

Best wishes,

Andy

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net<mailto:GeoTools-Devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/geotools-devel

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to