Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to implement a simple test of a OpenLayers + WFS-T + GeoServer -setup. I have followed the instructions by populating PostGIS and configuring GeoServer, and can see the WFS-T layer data in GeoServer's preview fine.

I am following these steps:

When I view the test page in browser, WSF-T layer is not displayed.

I have not defined proxypass to GeoServer (I have not done this:! This is because

  • I think this should not be necessary since I am testing my page only using file://somefolder/mytestpage.html URLs
  • My setup does not have Apache web server at all - GeoServer Windows installer did not install it
  • The symptoms do not sound like the problems are due to not using proxypass - there are no failed requests when I look at Firebug, and no "XMLHttpRequest cannot load Origin localhost is not allowed by Access-Control-Allow-Origin." errors

What I am weirded about it that when the page loads, the only request to localhost is OPTIONS request to /geoserver/wfs. There's no POST messages to localhost at all.

enter image description here

I have installed GeoServer in port 28080, and this is how I modified the source code from

  • disabled proxypass (just commented the whole row - is this how you do it?)
  • changed some parameters to reflect my environment: url: "http://localhost:28080/geoserver/wfs", geometryName: "geom", schema: "http://localhost:28080/geoserver/wfs/DescribeFeatureType?version=1.1.0&;typename=cite:wfst_test"


// disabled proxypass
// OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";

// wfs-t editable overlay
var wfs_layer = new OpenLayers.Layer.Vector("Editable Features", {
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
//projection: new OpenLayers.Projection("EPSG:26910"),
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
// loading data through localhost url path - jannem: use port 28080 as we have no apache proxy
url: "http://localhost:28080/geoserver/wfs",
featureNS :  "",
maxExtent: mapextent,
// layer name
featureType: "wfst_test",
// geometry column name
geometryName: "geom",
schema: "http://localhost:28080/geoserver/wfs/DescribeFeatureType?version=1.1.0&;typename=cite:wfst_test"

If I open localhost:28080/geoserver/wfs/ with browser, I get

<?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport version="2.0.0"
  xsi:schemaLocation=" http://localhost:28080/geoserver/schemas/ows/1.1.0/owsAll.xsd"
  xmlns:ows="" xmlns:xsi="">
  <ows:Exception exceptionCode="MissingParameterValue" locator="request">
    <ows:ExceptionText>Could not determine geoserver request from http request org.geoserver.platform.AdvancedDispatchFilter$AdvancedDispatchHttpRequest@7db12fce</ows:ExceptionText>

Any ideas?

EDIT: added two pictures for the discussion in the comments:

enter image description here enter image description here

share|improve this question
don't run from file://somefolder/mytestpage.html always use localhost:28080/geoserver/www/mytestpage.html this should fix your problem. – iant Oct 1 '12 at 14:32
Nice and simple, that fixed it! I don't fully understand why it works like that, though. Can you explain what happens in OpenLayers when I access the page using file:// and when I use localhost:28080 instead? – Janne Mattila Oct 2 '12 at 8:18
up vote 4 down vote accepted

To expand on my earlier comment for the benefit of Janne and other readers.

When you use OpenLayers to make a WFS (and WFS-T) request you need to be aware of the same-origin policy, this is a clever way to prevent unscrupulous web sites from running malicious javascript exploits on your web browser. Basically what it says is that if a javascript app wants to talk to the network it can only talk to the machine and port combination that it was served from.

This means that if you load a page from http:// localhost:8080 then that is the only place that your script can send requests to. Alternatively if you load your page from file://mytomcat/webapps/mypage.html your script can only send requests to file://mytomcat/... which isn't actually a server so it won't work.

share|improve this answer
Your suggestion fixed the problem, but can this really be same-origin problem? I am still confused about why I am not seeing any same-origin policy related error messages or failed requests in Firebug when I access the page using file:// URL? Also, when I load the page from http:// localhost:28080, that is not the only place my script can send requests to. It does send requests to for example (as I do not have a proxy configured), successfully. I am marking this as an answer as it fixed my problem, but would still very much love to understand what really is going on. – Janne Mattila Oct 2 '12 at 9:57
Your browser is probably not sending the requests as it "knows" they violate the same origin policy. The same origin policy only refers to data requests not images which is probably what you're requesting from google. – iant Oct 2 '12 at 10:00
Stupid browser, failing silently is confusing and makes it difficult to find the source of the problem while developing. I would much prefer to see an error somewhere, at least when I look at it with Firebug. That makes sense, thanks for the clarification. – Janne Mattila Oct 2 '12 at 10:05
Ummm....I have to say I still do not understand how this works. See the two images I added to original question. I am viewing the page from localhost:28080, and it fetches data (not images) from Isn't this violating same-origin policy? – Janne Mattila Oct 2 '12 at 10:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.