2
  • I have python2.7 and apache installed in my computer.
  • In proxy.cgi, I included in topline :

    #!/usr/bin/env python.exe -u;

  • I also added 'localhost:8080/geoserver' and 'localhost:80 in allowedhosts.
  • I moved the OpenLayers files to htdocs folder of apache.
  • I copied the cgi file to apche/cgi-bin.
  • Now, when I click on feature, popup appears but is empty.

Please help!! where my code went wrong? Given below is my code:

    <script type="text/javascript" src="http://localhost:8080/recipes/resources/ext/ext-all.js"></script>
    <link rel="stylesheet" type="text/css" href="http://localhost:8080/recipes/resources/ext/resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="http://localhost:8080/recipes/resources/ext/resources/css/xtheme-gray.css" />
    <link rel="stylesheet" href="http://localhost:8080/recipes/resources/openlayers/theme/default/style.css" type="text/css" />
    <link rel="stylesheet" href="http://localhost:8080/recipes/resources/app/theme/style.css" type="text/css" />
    <link rel="stylesheet" href="http://localhost:8080/recipes/resources/geoext/resources/css/gxtheme-gray.css" type="text/css" />
    <script src="http://localhost:8080/recipes/resources/openlayers/build/OpenLayers.js"></script>
    <script src="http://localhost:8080/recipes/resources/geoext/build/GeoExt.js"></script>
    <script>
        OpenLayers.ImgPath = "http://localhost:8080/recipes/resources/openlayers/img/";

        // the `panel` and `popup` variables are declared here for easy debugging
        var panel, popup;

        Ext.onReady(function() {
        OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";    
            // queryable WMS layer
            var zoning = new OpenLayers.Layer.WMS(
                "railroads",
                "http://localhost:8080/geoserver/usa/wms",
                {layers: "usa:states", format: "image/gif", transparent: "true"}
            );

            panel = new GeoExt.MapPanel({
                title: "MapPanel",
                renderTo: "map-id",
                height: 300,
                width: "100%",
                layers: [
                    new OpenLayers.Layer.WMS(
                        "Global Imagery",
                        "http://maps.opengeo.org/geowebcache/service/wms",
                        {layers: "openstreetmap", format: "image/png"}
                    ), 
                    zoning
                ],
                center: [-122.87, 42.34],
                zoom: 13
            });

            // create a control to get feature info from queryable layers
            var control = new OpenLayers.Control.WMSGetFeatureInfo({
                url: "http://localhost:8080/geoserver/usa/wms"
                title: 'Identify features by clicking',
                layers: [zoning],
            });
            panel.map.addControl(control);
            control.activate();

            // register a listener for the getfeatureinfo event on the control
            control.events.on({
                getfeatureinfo: function(event) {
                    // close existing popup
                    if (popup) {
                        popup.destroy();
                    }
                    popup = new GeoExt.Popup({
                        title: "Popup",
                        map: panel.map,
                        lonlat: panel.map.getLonLatFromPixel(event.xy),
                        width: 250,
                        autoScroll: true,
                        collapsible: true,
                        bodyStyle: {padding: 5},
                        html: event.text
                    });
                    popup.show();
                }
            });

        });

    </script>

enter image description here

After changing the path to wamp/www and still I am getting this new following error:

enter image description here

  • What does the console show in firebug or chrome? Does it contain any error? – Devdatta Tengshe Feb 26 '13 at 1:46
  • 1
    Additionally, have you confirmed that the proxy is working? – Devdatta Tengshe Feb 26 '13 at 1:47
  • I am getting this error in console in chrome when I click on the feature : XMLHttpRequest cannot load file:///C:/cgi-bin/proxy.cgi?url=http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%…D469%26y%3D118%26height%3D273%26width%3D1304%26info_format%3Dtext%252Fhtml. Cross origin requests are only supported for HTTP. OpenLayers.js:1081 cXMLHttpRequest.send OpenLayers.js:1081 (anonymous function) OpenLayers.js:867 Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 OpenLayers.js:1081 cXMLHttpRequest.send OpenLayers.js:1081 (anonymous function) OpenLayers.js:867 – GP92 Feb 26 '13 at 8:44
  • 1
    You have installed WAMP and have placed your html file there. Why then are you accessing it using the file protocol? Access it using the http Prootocol. SOmething like localhost/featureinfo.html. (One more problem is is that if you have installed Wamp, your HTML/Javascript files should be in C:\Wamp\www and not C:\Wamp\bin\Apache\htdocs) – Devdatta Tengshe Feb 26 '13 at 8:56
  • Yes thankyou!! it worked. but still there is problem. Now popup shows an error instead of being empty like before. I will attach the new snapshot – GP92 Feb 26 '13 at 9:08
3
+50

A 500 error indicates that the server is having problems. This tells me that the proxy is not configured properly.

To solve the issue, I would check the following:

  1. Are you on a Linux/Unix Machine? The path #!/usr/bin/env python.exe -u; is usually for linux systems. My proxy file on a windows machine has the following as the first line: #!C:/Python27/Python.exe -u

  2. You need to add the external IP/domain name in the allowedHosts. so it should not be localahost:8080 but 115.241.55.138:8080

  3. You need to check the logs of your web-server for any other errors.

  4. You need to confirm that the proxy is in fact working. If you are using the OpenLayers Proxy, just visit the proxy at http:\\115.241.55.138\cgi-bin\proxy.cgi and see if the OpenLayers Website comes up.

  • no..I did the first 2 steps. I dont know how to anything regarding the configuration of web-server..help!! – GP92 Mar 2 '13 at 10:18
  • I changed the path to #!C:\Python25\python.exe -u and also my present ip address. but when I visit the proxy, it is showing internal service error. – GP92 Mar 2 '13 at 10:38
  • 1
    Look in your web server logs. You will get the detailed error there. – Devdatta Tengshe Mar 2 '13 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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