1

I am having a strange problem while trying to display WFS on a map using Open Layers 3 and Geoserver. I am using a Tomcat 7 servlet, and the maps are located in a directory inside the WebApps folder. I am using Windows 7. Here's the code I am using for the map.

var gad = new ol.source.GeoJSON({
    'projection': map.getView().getProjection(),
    url: 'http://localhost:8080/geoserver/wfs?DATASTORE=Framework&service=wfs&version=2.0.0&request=GetFeature&typeName=opengeo:addr_to_geocode&outputFormat=application/JSON'
});

var gad3 = new ol.layer.Vector({
    title: "Name",    
    source: gad,
    style: new ol.style.Style({
        image: new ol.style.Circle(({
            radius: 3,
    fill: new ol.style.Fill({color: 'yellow'})

        }))
    })
});
map.addLayer(gad3);

I've created a similar map on my Ubuntu computer and it loads without any problems.

When I load the map, only one point is plotted on the map at the equator. All of the styles are loaded correctly (I've tried this with a bunch of different layers and styles), but instead of things being plotted where they are supposed to go, there is just one marker at the equator.

When I enter the url for the GetFeature request in my browser, I get to the page that I want to get to. Also, if I try to load the same map using WMS instead of WFS it works properly.

I've opened DevTools in Chrome and there are no problems listed in the console. I'm not very good at diagnosing problems through DevTools or Firebug.

Any idea what could possible be causing this problem?

Not sure if this is relevant, but one difference between console output in my ubuntu laptop and windows desktop is that transfer encoding is chunked on my laptop. Also, nothing shows up for content length on my desktop.

I tried loading the WFS layer onto QGIS. When I tried to do it, I got the following error.

The layer http://localhost:8080/geoserver/wfs?DATASTORE=Framework&version=1.1.0&typeName=cite:tropics&outputFormat=application/JSON&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=sf:restricted&SRSNAME=EPSG:26713&username=admin&password=geoserver is not a valid layer and can not be added to the map. 

Things worked as expected for the WMS layer.

I tried to check if the geoJSON was valid using geoJSONlint. I cut and paste the output from the WFS call in, and everything plotted correctly.

Not sure if this is relevant, but I had this same problem when I installed geoserver inside Jetty instead of Tomcat 7.

Some additional information: All the data I am using on the Ubuntu laptop and Windows desktop come from identical databases (I created the desktop database by using pg_dump and pg_restore)


I got the WFS to load on QGIS. Turns out the url was too long for QGIS to handle which was I was getting the error messages. Is this in any way relevant to my current problem?

Problem solved, sort of. I got a new computer at work, and everything works fine. I haven't the slightest clue what the old problem was tho.

closed as off-topic by underdark Oct 16 '16 at 9:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – underdark
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Are the client (the browser) and the server (tomcat) really on the same machine? – BradHards Dec 17 '14 at 4:06
  • I think they are. Is it possible for the server and browser to appear to be on the same machine and be on different ones? – Ravi Mehta Dec 17 '14 at 4:09
  • If the machine you are logged into when you use the browser and the machine you have your Tomcat installed on are the same, then its the same machine. Surely you can tell which machine you're using! – BradHards Dec 17 '14 at 4:24
  • Yes. They are both on the same machine. I was just being obtuse. – Ravi Mehta Dec 17 '14 at 4:29
  • Did u checked error/warning message in Chrome/Firefox (Debugger). It may be related to CORS. – AST Dec 17 '14 at 7:19

Browse other questions tagged or ask your own question.