I want to retrieve the feature Collection from a WFS server with the Java library GeoTools. I tried this code, but unfortunately the program fails to execute.

public class App {
public static void main( String[] args ) throws IOException{
    String getCapabilities = "http://localhost:8081/geoserver/wfs?REQUEST=GetCapabilities&version=1.0.0";

    Map connectionParameters = new HashMap();
    connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", getCapabilities );
    WFSDataStoreFactory  dsf = new WFSDataStoreFactory();
    try {
        WFSDataStore dataStore = dsf.createDataStore(connectionParameters);
        SimpleFeatureSource source = dataStore.getFeatureSource("Gruen:Gruenflaechen");
        SimpleFeatureCollection fc = source.getFeatures();

        while(fc.features().hasNext()){             //line 33
            SimpleFeature sf = fc.features().next();

    } catch (IOException ex) {

By running this code, I get an IllegalArgumentException at line 33.

Exception in thread "main" java.lang.IllegalArgumentException: Server does not support 'text/xml; subtype=gml/3.1.1' output format: [text/xml; subType=gml/3.1.1/profiles/gmlsf/1.0.0/0]

The output also says that it can't decode CRS EPSG:25832 for Gruen:Gruenflaechen and that I would create a location and a shape with null CoordinateReferenceSystem

I have no idea how to solve this problem and as you might have noticed I am not really a GIS expert. All I want to do is to receive the Geodata from the WFS and save it into an own Java Object. Would be very grateful for help!


Okay, I found the solution. I just had to add a connectionParameter:

connectionParameters.put("WFSDataStoreFactory:OUTPUTFORMAT", "text/xml; subType=gml/3.1.1/profiles/gmlsf/1.0.0/0");
| improve this question | | | | |
  • 2
    Your solution should be posted below as the "Answer", so you can close this off. It might seem a bit strange, but think "Q&A site", rather than "forum site". – BradHards Nov 7 '14 at 9:41