Issue 338 in geoext-viewer: Clicking on "Download" in featureinfo table redirects to heron.cgi located on localhost

292 views
Skip to first unread message

geoext...@googlecode.com

unread,
Feb 21, 2014, 4:34:36 AM2/21/14
to geoext-vi...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Project-None

New issue 338 by bhanu.ma...@gmail.com: Clicking on "Download" in
featureinfo table redirects to heron.cgi located on localhost
http://code.google.com/p/geoext-viewer/issues/detail?id=338

Whenever I click to download displayed featureinfo of an active layer (
doesnt matter which format), my browser redirects it to heron.cgi located
on localhost.
I'm using windows 7 and tried this on mozilla, chrome and Internet explorer





can anyone explain the possible reason ??

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

geoext...@googlecode.com

unread,
Feb 21, 2014, 8:04:15 AM2/21/14
to geoext-vi...@googlegroups.com
Updates:
Status: Started

Comment #1 on issue 338 by jus...@gmail.com: Clicking on "Download" in
featureinfo table redirects to heron.cgi located on localhost
http://code.google.com/p/geoext-viewer/issues/detail?id=338

This sounds like you have not installed heron.cgi or maybe not even Heron
on a webserver. Best is to follow the installation steps like here:
http://heron-mc.org/tutorials/quickstart.html#download-and-go

In general this is more of a question than a defect it seems like. Could
you pose this as a question on the Heron mailing list? See
http://groups.google.com/group/geoext-viewer-devel

With these kind of questions it helps a whole lot if you could provide more
information and context, like which version of Heron, how you have
installed it etc. We are not with you behind the same computer, so how can
we know your context?

geoext...@googlecode.com

unread,
Feb 23, 2014, 4:01:11 AM2/23/14
to geoext-vi...@googlegroups.com

Comment #2 on issue 338 by bhanu.ma...@gmail.com: Clicking on "Download" in
featureinfo table redirects to heron.cgi located on localhost
http://code.google.com/p/geoext-viewer/issues/detail?id=338


okay , i will try to explain my situation :

I'm using apache tomcat 7.0 , and i have deployed geoserver 2.4.4 on it. I
have installed heron-1.0.0 in the root directory of apache tomcat.
I can access http://localhost:8080/heron-1.0.0/examples/default , but i
dont get any featureinfo when clicking on any feature . I have configured
proxy.cgi to include url : 'localhost:8080' under "allowedHosts" .

On the other hand , i have created my own html file , which i run through
another folder located in tomcat's root directory . This html uses code
collected and stitched together from various examples hosted on
heron-mc.org. I havent included any proxy.cgi configuration in this folder
or html file. Instead, I have installed a reverse proxy servelet , called
j2ep-1.0 , and it allows me to get featureinfo on all the layers and
features. This html file runs successfully . Only problem being not able to
download the featureinfo displayed in the featureinfo panel. Clicking on
the download button results in redirection of webpage to
http://localhost:8080/heron.cgi
I have attached my custom made html file , please take a look around to
find any thing i missed to add up.

I am a civil engineer and do not have advanced knowledge of any computer
language whatsoever, I have just collected the code from various examples
and stitched it together to create my own geoext-viewer.

I hope this elaborates the problem a little. If there is anything else to
clear , i will be happy to explain

thanks


Attachments:
index.html 11.1 KB

Davor Racic

unread,
Feb 23, 2014, 4:07:53 AM2/23/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Have you configured tomcat to run cgi scripts?

geoext...@googlecode.com

unread,
Feb 23, 2014, 11:44:10 PM2/23/14
to geoext-vi...@googlegroups.com

Comment #3 on issue 338 by bhanu.ma...@gmail.com: Clicking on "Download" in
featureinfo table redirects to heron.cgi located on localhost
http://code.google.com/p/geoext-viewer/issues/detail?id=338

Update : Please consider the new index.html attached along this comment .

Attachments:
index.html 10.4 KB

Bhanu Magotra

unread,
Feb 24, 2014, 12:01:47 AM2/24/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com


On Sunday, February 23, 2014 2:37:53 PM UTC+5:30, Davor Racic wrote:
Have you configured tomcat to run cgi scripts?



thank you !! ... I will follow the steps and report back  

Bhanu Magotra

unread,
Feb 24, 2014, 12:26:58 AM2/24/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com


On Sunday, February 23, 2014 2:37:53 PM UTC+5:30, Davor Racic wrote:
Have you configured tomcat to run cgi scripts?



After following the steps given in the above link , following links started to give error 404

localhost:8080/geoserver ( directory hosting geoserver 2.4.4)
localhost:8080/myapp/(directory hosting my index.html)

although i am able to access localhost:8080 but not http://localhost:8080 .. i dont understand the reason
Also, Instead of creating following cgi file as mentioned in steps :
1
2
3
4
#!C:\Perl\bin\perl.exe
# filename: test1.cgi
print "Content-type: text/html\n\n";
print "Hello, world!\n"
I  simply copied heron.cgi in the folder WEB-INF/cgi  

Davor Racic

unread,
Feb 24, 2014, 1:59:05 AM2/24/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Ok, this is the proper way to to this on Tomcat. First you create META-INF/context.xml file in yout app directry with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<Context privileged="true">
<loader delegate="false" />
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

And then yout create WEB-INF/web.xml file with the following content

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My App Name</display-name>
<servlet>
<servlet-name>cgi-bin</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi-bin/</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
<init-param>
<param-name>executable</param-name>
<param-value>/usr/bin/python</param-value>
</init-param>
<init-param>
<param-name>passShellEnvironment</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>cgi-bin</servlet-name>
<url-pattern>/cgi-bin/*</url-pattern>
</servlet-mapping>
</web-app>

Then you create WEB-INF/cgi-bin folder and put cgi scripts over there, and make them executable.

Davor Racic

unread,
Feb 24, 2014, 2:05:52 AM2/24/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Also you have to Remove the XML comments from around the CGI servlet and servlet-mapping configuration in $CATALINA_BASE/conf/web.xml if they exist, and of course restart Tomcat. If you run on Windows, you have to install Python, and change:

<param-value>/usr/bin/python</param-value>

To the location of python.exe
Message has been deleted

Bhanu Magotra

unread,
Feb 25, 2014, 5:30:21 AM2/25/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Ok using all your instructions, I have taken following steps :

1. I created my META-INF and WEB-INF folders in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\viewer , ( viewer is the folder which contains my index.html file for mapping client)
2. Created context.xml with the code provided by you in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\viewer\META-INF\context.xml
3. Created web.xml using your code in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\viewer\WEB-INF\web.xml.
4. Included path for python in the web.xml code as "C:\Python27\ArcGIS10.1\python.exe
5. Created cgi-bin in C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\viewer\WEB-INF\cgi-bin
6. Copied heron.cgi from heron-1.0.0 and copied it to C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\viewer\WEB-INF\cgi-bin\heron.cgi
7. Removed comments from  CGI servlet and servlet-mapping configuration  $CATALINA_BASE/conf/web.xml

After restarting Tomcat, all localhost:8080 links are working . But, clicking on download featureinfo still redirects to heron.cgi

Also, the browser is picking heron.cgi from:
   C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\cgi-bin 
 instead of 
 C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\viewer\WEB-INF\cgi-bin

If i delete the cgi-bin folder from  C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\cgi-bin  , I get error 404 in the browser when clicking on download featurinfo

Any suggestions??

Bhanu Magotra

unread,
Feb 26, 2014, 12:45:03 AM2/26/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
One more observation I made today :

I created a test.cgi with very simple code from internet and saved  it in  C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\viewer\WEB-INF\cgi-bin 
and when i opened the test.cgi in browser , it worked. So this means  that the instructions you gave me for configuring apache tomcat to run cgi script was successfull.


However, If I try to open following link : localhost:8080/viewer/cgi-bin/heron.cgi , I get the following error :

Heron CGI - Error

Please supply query parameter mime


Now there are two problems :
1. How to eliminated this Heron CGI Error .
2. When actually clicking on "download" in featurinfo table, the browser does not redirects to 
instead , it redirects to 
http://localhost:8080/cgi-bin/heron.cgi ...and opens the code of cgi file as shown below :

#!C:\Python27\ArcGIS10.1\python.exe
#
# heron.cgi - generic RESTful services for Heron
#
# This CGI provides Heron services that can only/better be handled
# within a server. The setup is generic: a parameter 'action' determines
# which function is to be called. The other parameters are specific to
# each handler. When using any data conversions and reprojections, the program
# ogr2ogr from GDAL/OGR (www.gdal.org) is required to be installed on your system.

# Global var: name or path of the GDAL/OGR utility: ogr2ogr
# In many cases the program is found via the PATH variable,
# but in some cases, mostly with custom installs, one may change
# this variable to the full pathname where ogr2ogr resides.
# For example: OGR2OGR_PROG = '/usr/local/bin/ogr2ogr'.
# Also note that the GDAL_DATA global var may be required for reprojections.
OGR2OGR_PROG = 'ogr2ogr'

import cgi
import cgitb
import base64
import zipfile
import subprocess
import os
import tempfile
import sys
import shutil
from StringIO import StringIO


cgitb.enable()

# Get form/query params
params = cgi.FieldStorage()


def print_err(*args):
    sys.stderr.write(' '.join(map(str,args)) + '\n')


def send_error(reason='Unknown'):
    print('Content-Type: text/html')
    print('')
    print('<h2>Heron CGI - Error</h2>')
    print(reason)


def send_param_error(reason, param_name='Unknown'):
    send_error(reason + ' <i>%s</i>.' % param_name)


def param_available(param_names):
    for param_name in param_names:
        if param_name not in params:
            send_param_error('Please supply query parameter', param_name=param_name)
            return False

    return True




Can u help me to eliminate the issues? 

Michael Räder

unread,
Feb 26, 2014, 3:19:33 AM2/26/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
#!c:/%YOURPATH%Python27/python.exe -u

"""This is a blind proxy that we use to get around browser
restrictions that prevent the Javascript from loading pages not on the
same server as the Javascript.  This has several problems: it's less
efficient, it might break some sites, and it's a security risk because
people can use this proxy to browse the web and possibly do bad stuff
with it.  It only loads pages via http and https, but it can load any
content type. It supports GET and POST requests."""

import urllib2
import cgi
import sys, os

# Designed to prevent Open Proxy type stuff.

proxy_info = {
'user' : 'username',
'pass' : 'password',
'host' : "",
'port' : 8080 # or 8080 or whatever
}

# build a new opener that uses a proxy requiring authorization
proxy_support = urllib2.ProxyHandler({"http" : \
"http://%(user)s:%(pass)s@%(host)s:%(port)d" % proxy_info})
opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

# install it
urllib2.install_opener(opener)

allowedHosts = [' ........']

method = os.environ["REQUEST_METHOD"]

Just van den Broecke

unread,
Feb 26, 2014, 7:02:44 AM2/26/14
to geoext-vi...@googlegroups.com
Hi,

On 26-02-14 06:45, Bhanu Magotra wrote:
> One more observation I made today :
>
> I created a test.cgi with very simple code from internet and saved it
> in C:\Program Files\Apache Software Foundation\Tomcat
> 7.0\webapps\viewer\WEB-INF\cgi-bin
> and when i opened the test.cgi in browser , it worked. So this means
> that the instructions you gave me for configuring apache tomcat to run
> cgi script was successfull.
>
>
> However, If I try to open following link :
> localhost:8080/viewer/cgi-bin/heron.cgi , I get the following error :
>
>
> Heron CGI - Error
>
> Please supply query parameter /mime/
This is actually a good sign: heron.cgi is found and executed by Python.
It only requires parameter names as Heron via Download will supply.
>
>
>
> Now there are two problems :
> 1. How to eliminated this Heron CGI Error .
See above, that is not an error.
> 2. When actually clicking on "download" in featurinfo table, the browser
> does not redirects to
> http://localhost:8080/viewer/cgi-bin/heron.cgi
> instead , it redirects to
> http://localhost:8080/cgi-bin/heron.cgi ...and opens the code of cgi
> file as shown below :
The default URL for heron.cgi is /cgi-bin/heron.cgi, hence this becomes
http://localhost:8080/cgi-bin/heron.cgi. You can override this location
via the following setting in your Config.js (after your Heron.js include):

Heron.globals.serviceUrl = 'cgi-bin/heron.cgi';
or
Heron.globals.serviceUrl = '/viewer/cgi-bin/heron.cgi';

See also http://heron-mc.org/tutorials/workshop.html#server-components

best,

Just
> --
> --
> You received this message because you are subscribed to the Google
> Groups "geoext-viewer-devel" group.
> To post to this group, send email to
> geoext-vi...@googlegroups.com
> To unsubscribe from this group, send email to
> geoext-viewer-d...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/geoext-viewer-devel?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Heron Mapping Client Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to geoext-viewer-d...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Bhanu Magotra

unread,
Feb 27, 2014, 6:59:51 AM2/27/14
to geoext-vi...@googlegroups.com, jus...@gmail.com

Hi Just , thankyou for helping.

After adding Heron.globals.serviceUrl , following two things are happening

1. If I add Heron.globals.serviceUrl = 'cgi-bin/heron.cgi';  .. the browser again redirects to http://localhost:8080/cgi-bin/heron.cgi and opens up the code written in that script.

2. If I add Heron.globals.serviceUrl = '/viewer/cgi-bin/heron.cgi';  .. the browser redirects to  http://localhost:8080/viewer/viewer/cgi-bin/heron.cgi and gives Error-404.  I dont know why it is looking for two viewer directories instead of only one.

Any Idea???

Thanks
Bhanu

On Wednesday, February 26, 2014 5:32:44 PM UTC+5:30, Just van den Broecke wrote:.
> For more options, visit this group at
> http://groups.google.com/group/geoext-viewer-devel?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Heron Mapping Client Development" group.
> To unsubscribe from this group and stop receiving emails from it, send

Just van den Broecke

unread,
Feb 27, 2014, 7:14:08 AM2/27/14
to Bhanu Magotra, geoext-vi...@googlegroups.com
Hi Bhanu,

I am not fmailiar with CGI in Tomcat, but just like in Apache HTTP
server you designate particular directories to contain cgi-scripts not
just any directory (think of the security implications!). I think the
/viewer/viewer is caused by Tomcat's container but there's still some
combinations left....

But appearantly Tomcat was configured to contain cgi under
webapps\viewer\WEB-INF\cgi-bin, which makes sense since files there are
never exposed. Since your test worked my guess is that you place
heron.cgi under \WEB-INF\cgi-bin and use the same URL in
Heron.globals.serviceUrl as you used for test.cgi.

But IMO, Tomcat is a bit heavy and not my first choice for CGI, so why
not use a Python webserver as in the Heron .zip install root dir:
startheron.py ? best, Just
> <http://localhost:8080/cgi-bin/heron.cgi>. You can override this
> location
> via the following setting in your Config.js (after your Heron.js
> include):
>
> Heron.globals.serviceUrl = 'cgi-bin/heron.cgi';
> or
> Heron.globals.serviceUrl = '/viewer/cgi-bin/heron.cgi';
>
> See also
> http://heron-mc.org/tutorials/workshop.html#server-components
> <http://heron-mc.org/tutorials/workshop.html#server-components>
>
> best,
>
> Just
>
> >
> > #!C:\Python27\ArcGIS10.1\python.exe
> > #
> > # heron.cgi - generic RESTful services for Heron
> > #
> > # This CGI provides Heron services that can only/better be
> handled
> > # within a server. The setup is generic: a parameter 'action'
> determines
> > # which function is to be called. The other parameters are
> specific to
> > # each handler. When using any data conversions and
> reprojections, the program
> > # ogr2ogr from GDAL/OGR (www.gdal.org <http://www.gdal.org>)
> > geoext-vi...@googlegroups.com <javascript:>
> > To unsubscribe from this group, send email to
> > geoext-viewer-d...@googlegroups.com <javascript:>
> > For more options, visit this group at
> > http://groups.google.com/group/geoext-viewer-devel?hl=en
> <http://groups.google.com/group/geoext-viewer-devel?hl=en>
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Heron Mapping Client Development" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to geoext-viewer-d...@googlegroups.com
> <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>

Davor Racic

unread,
Feb 27, 2014, 12:02:23 PM2/27/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Please look at your tomcat (not viewer) web.xml configuration file and see if you have this mime mapping:

    <mime-mapping>
        <extension>zip</extension>
        <mime-type>application/zip</mime-type>
    </mime-mapping>

If you don't have it, add it.... 
 

Davor Racic

unread,
Feb 27, 2014, 12:09:08 PM2/27/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Try this way so tomcat cgi-bin folder and your viewer cgi-bin folder don't interfere:

Rename WEB-INF/cgi-bin to WEB-INF/proxy

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My App Name</display-name>
<servlet>
<servlet-name>proxy</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/proxy/</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
<init-param>
<param-name>executable</param-name>
<param-value>/usr/bin/python</param-value>
</init-param>
<init-param>
<param-name>passShellEnvironment</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>proxy</servlet-name>
<url-pattern>/proxy/*</url-pattern>
</servlet-mapping>
</web-app>

The put in your config.js file:

Heron.globals.serviceUrl = 'proxy/heron.cgi'; 

geoext...@googlecode.com

unread,
Feb 28, 2014, 6:32:35 AM2/28/14
to geoext-vi...@googlegroups.com
Updates:
Status: WontFix

Comment #4 on issue 338 by jus...@gmail.com: Clicking on "Download" in
featureinfo table redirects to heron.cgi located on localhost
http://code.google.com/p/geoext-viewer/issues/detail?id=338

I now see that most of the discussion is within the mailing list. This is
also the place where it belongs, since it is a request for help, not (yet)
a bug. If a bug comes out we'll reopen this issue.

See a link to the thread below in the mailing list to following the
discussion. Hopefully things are working by now.

https://groups.google.com/forum/#!topic/geoext-viewer-devel/bFl65qkjZvc

Bhanu Magotra

unread,
Mar 3, 2014, 3:41:57 AM3/3/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Hi Davor and Just ..thank you for your valuable suggestions 

After adding following line to my config.js , i was able to execute heron.cgi located within my viewer drectory :

Heron.globals.serviceUrl= './cgi-bin/heron.cgi';

The script is able to work but now I am facing strange issues when clicking on download button in featureinfo table . These issues are "download format" specific :

1. CSV = clicking on this format results in download of a file "heron.cgi" which after changing extension to ".csv"  opens up the attributes of downloaded features

2. XLS = same as CSV , changing to ".xls" opens the attribute table in excel

3. ESRI zip = gives an error in browser , under the heading : <type 'exceptions.WindowsError'> . I am attaching my error report as txt file with this message

4. GeoJSON and WKT = clicking on them opens up the data to b downloaded in the browser window ( it looks like correct data , its not an error) .. but it is not downloaded on the hard disk


Any thoughts or suggestions??
esri zip error.txt

Bhanu Magotra

unread,
Mar 4, 2014, 3:41:53 AM3/4/14
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
I've installed GDAL libraries and set system variables accrodingly. When executing "ogr2ogr" in cmd , i dont get any error . It displays some random information which is supposed to mean that GDAL installation is successfull.

Also, after GDAL installations , <type 'exceptions.WindowsError'> does not come when clicking on "download ESRI zip"  , instead a file "heron.cgi" is downloaded but it becomes corrupted when extension is changed to ".zip"

Aissam AKHBAZ

unread,
May 25, 2015, 7:05:39 AM5/25/15
to geoext-vi...@googlegroups.com, codesite...@google.com, geoext...@googlecode.com
Hello Bhanu Magotra, I have the same problem as you, that have to do with the heron.cgi downlaoded instead, in the case of .xls, csv and .zip that must contain the shapeFile ESRI file.  for shp I get the same problem  << When file "heron.cgi" is downloaded  it becomes corrupted when extension is changed to ".zip">>.

PLEASE tell me if have any Idea to handle this, did you solve the problem, tell me please it's urgent!!

Abraham Coiman

unread,
May 23, 2017, 4:44:27 PM5/23/17
to Heron Mapping Client Development, codesite...@google.com, geoext...@googlecode.com
I had a similar problem. When clicking download  on Drawing Tools it redirects to heron.cgi located on localhost and shows the text.

I fixed it by using this recommendation
https://askubuntu.com/questions/54251/how-do-i-make-apache-run-a-cgi-instead-of-showing-the-text
Reply all
Reply to author
Forward
0 new messages