I'm running geoserver-2.5.2. From an external server i would like to call it as a wfs source with ol3. For this I would like to allow this external server to access the data. It seams I need a header for cross-origin resource sharing (CORS). Like Zia has tried here, the link wasn't helpful to me as well, as geoserver didn't work anymore after editing the web.xml file the way as described in the link.

I believe I do need the access for calling the wfs data.


4 Answers 4


I know you post this question from along time but i'm just solve the problem.

I faced the same problem myself and i tried many solutions that discussed here or in other forums and finally i managed to solve the problem of enabling the Cross Origin in Geoserver.

After many trials i discovered that the solution is pretty simple following the exact steps that found in the Jetty webpage Jetty Cross Origin Filter.

But with a small change, the page said that we have to copy the following Cross-Origin filter to the (Web.xml) configuration file, but the solution that worked with me is copying this filter xml configuration in to (webdefault.xml) configuration file, when applying this change the geoserver worked like a charm and i could run any WFS, WMS GetFeatureInfoRequest in JSON format using AJAX instead of using IFrame soultion.

I'm using the following software versions:

  • Boundless OpenGeo v4.5 .
  • Geoserver v 2.6.2 .
  • Jetty v 7.6.13.v20130916 .

Here is the detailed steps:

  1. Download the matched version of the Jetty servlets according to your jetty version from this page Jetty Servlets .
  2. In this example i'm using jetty v7.6.13.v20130916 so the jar file should be named
    (jetty-servlets-7.6.13.v20130916.jar) the filename will be different according to the jetty version - don't change its name because jetty matching the servlet name with its version like :
    jetty-servlets-<%JETTY_VERSION%>.jar, so don't rename it.
  3. Stop the (GeoServer, Postgres) services and Take a copy from the OpenGeo directory located in
    (C:\Program Files (x86)\boundless\OpenGeo) and also Copy the OpenGeo directory located in
    (C:\ProgramData\boundless\OpenGeo) before starting this tutorial, as a precaution step.

  4. Copy the file (jetty-servlets-7.6.13.v20130916.jar) (As-is) into the jetty Lib directory
    (*C:\Program Files (x86)\boundless\OpenGeo\jetty\lib*) also the directory may change according your installation directory.

  5. Copy and paste the following xml lines into the (webdefault.xml) located in
    (C:\Program Files (x86)\boundless\OpenGeo\jetty\ect\webdefault.xml), i'm not sure that the location for these lines to place in the file is important or not but i paste them starting from line #306 after </serlet-mapping>.
  1. Start the (GeoServer, Postgres) services, wait for a few seconds and browse to the geoserver page, the geoserver will start correctly.

This tutorial worked for me and i hope it work for anyone facing the same problem.

  • Does this address the specific question being asked?
    – PolyGeo
    Apr 16, 2015 at 8:54
  • 1
    It address the same problem but in different Geoserver version
    – Ahmed GIS
    Apr 16, 2015 at 10:10
  • @AhmedGIS Hello. This is a nice answer. I try to upgrade my Geoserver version 2.1.3 because it runs Jetty version 6.1.8 and I cannot find jars for that version. In my system I have Geoserver, Openlayers and PostGIS, not Boundless. Do you know if Geoserver 2.8.0 (the latest), runs a higher version of Jetty? Or did you updated Jetty and then passed the jars? Check this please http://gis.stackexchange.com/questions/165145/what-version-of-jetty-the-geoserver-runs. Thank you
    – slevin
    Oct 2, 2015 at 22:16

fwiw enable-cors.org is a great general resource for server or client configurations, in case you are deploying with Tomcat, for example.


Just to mention, Geoserver recently release 2.9-RC1, which comes with the more updated jetty (v9+) that supports CORS. Similar to the one mentioned by Ahmed GIS, you need to download the correct version of the jetty servlets. But this time, it is to copy into the directory "\WEB-INF\lib", and to edit the file "WEB-INF\web.xml" instead.


For GeoServer 2.8 I resolve by this procedure:


I tried implement to GeoServer 2.9 but can't resolve this problem so I re-installed GeoServer 2.8 and works.

  • 2
    Links can disappear over time. Please edit your answer to include the steps you followed to keep this answer relevant.
    – Midavalo
    Jul 3, 2016 at 0:49

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