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:
- Download the matched version of the Jetty servlets according to your jetty version from this page Jetty Servlets .
- 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.
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.
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.
- 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>.
<filter>
<filter-name>cross-origin</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
- 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.
jarsfor 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 thejars? Check this pleasehttp://gis.stackexchange.com/questions/165145/what-version-of-jetty-the-geoserver-runs. Thank you – slevin Oct 02 '15 at 22:16