[geotk] NullPointerException with WFSFeatureStore
johann sorel
johann.sorel at geomatys.com
Tue Dec 9 23:49:12 PST 2014
Hello,
I think you can increase the timeout to 60s and throw an exception. I am
currently occupied with other tasks so if you have a few minutes to
spare, you should be able to make the changes.
Johann
On 10/12/2014 07:02, Martin Desruisseaux wrote:
> Hello Emmanuel
>
> I just had a look in the code. I saw a hard-coded timeout of 10
> seconds in the WebFeatureClient class (line 154 and 158). Would it be
> possible that the server queried by your application take more than 10
> seconds to answer?
>
> Hello Johann
>
> I case of timeout, the WebFeatureClient.getCapabilities() method at
> line 159 logs a warning and returns null. However the Javadoc does not
> said that this method may return null, and indeed the
> WFSFeatureStore.checkTypeExists() method at line 114 does not verify
> if the WFSCapabilities object is null, which causes the
> NullPointerException. What would be the appropriate behaviour?
>
> * In case of failure, let WebFeatureClient throws an exception? (my
> preferred choice, since otherwise we get a NullPointerException
> anyway, which is much less informative).
> * In case of failure, have WebFeatureClient to return an empty
> WFSCapabilities? (I don't think it would be safe, since the caller
> does not know that there is a problem).
> * Document that WebFeatureClient.getCapabilities() may return null
> in case of failure, and revisit all caller code for making them
> null-safe?
>
>
> Martin
>
>
>
> Le 09/12/14 07:18, Emmanuel Blondel a écrit :
>> Hello,
>>
>> I'm currently assessing the WFS client from Geotoolkit. We would like
>> to use it in a new project (also because we would like to use Apache
>> SIS progressively), with the purpose to discover featuretypes and
>> fetch the featureCollection data, relying on the official GeoAPI.
>>
>> I've been trying to use Geotoolkit 4.0-M2 (which AFAIK is the latest
>> milestone release), and the geotk-wfs-client.
>>
>> I get the following stack trace :
>>
>> /déc. 08, 2014 11:11:58 PM org.geotoolkit.data.wfs.WebFeatureClient
>> getCapabilities//
>> //AVERTISSEMENT: TimeOut error, the server takes too much time to
>> answer. //
>> //Exception in thread "main" java.lang.NullPointerException//
>> // at
>> org.geotoolkit.data.wfs.WFSFeatureStore.checkTypeExist(WFSFeatureStore.java:114)//
>> // at
>> org.geotoolkit.data.wfs.WFSFeatureStore.<init>(WFSFeatureStore.java:107)//
>> // at org.fao.fi.wfstesting.App.main(App.java:33)/
>>
>>
>> for this code:
>>
>> final WebFeatureClient wfsServer = new WebFeatureClient(new
>> URL("http://www.fao.org/figis/geoserver/ows"), "1.1.0");
>> final GetCapabilitiesRequest getCapa =
>> wfsServer.createGetCapabilities();
>>
>> final GetFeatureRequest getFeature =
>> wfsServer.createGetFeature();
>> //simplify WFS like a datastore
>> final FeatureStore store = new WFSFeatureStore(wfsServer);
>>
>> String[] typeNames = store.getTypeNames();
>> for(String typeName : typeNames){
>> FeatureType ft = store.getFeatureType(typeName);
>> System.out.println(ft.getName());
>> System.out.println("==");
>> }
>>
>> I admit i'm lost. I had a look to the code for which i identified the
>> timeout warning.
>> But nothing about the exception. Any idea?
>>
>> Thanks in advance for your help
>> Emmanuel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20141210/891e9016/attachment.html>
More information about the Geotoolkit
mailing list