File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes CGI client cannot contact web Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "CGI client cannot contact web" Watch "CGI client cannot contact web" New topic
Author

CGI client cannot contact web

Deb Thompson
Greenhorn

Joined: Nov 03, 2004
Posts: 5
I have a PERL routine I've used for some time on Windows systems to retrieve and save a backup copy of a URL using the LWP::Simple head and getstore methods. For a project, I just set up a new server with J2EE and Tomcat. The same methods that work fine for me on Windows will not work when served through Tomcat. It appears that the routine is not being allowed to make an HTTP connection. I know the code and PERL setup are correct, as the routine will work through the command prompt on this same machine.

I suspect that this is an issue with the server setup, but I can't figure out what parameters need to be reset. I'd appreciate any suggestions that others might have.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
Exactly how are you executing the PERL program? Are you using the CGI servlet? Your PERL program may depend on environment variables that are not getting set.
Does the PERL program execute completely or hang?
Which Tomcat version?
Bill
Deb Thompson
Greenhorn

Joined: Nov 03, 2004
Posts: 5
For testing purposes, I'm calling the script as a URL from the browser. I modified the web.xml file to map cgi as a servelet. Does it matter that I'm using .pl as my file extension, but this isn't defined anywhere in the mapping?

The PERL routine does execute. It checks for the URL header, and doesn't find anything.

I'm using Tomcat version 5.0.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
If this was my problem I would try executing a PERL script that just dumps all the environment variables. Here is one that came with my Perl dist.



Bill
Deb Thompson
Greenhorn

Joined: Nov 03, 2004
Posts: 5
I got the environment variables, but I don't think I see anything that tells me what's going wrong:

AUTH_TYPE=
CONTENT_LENGTH=
CONTENT_TYPE=
GATEWAY_INTERFACE=CGI/1.1
HTTP_ACCEPT=image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/pdf, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_ACCEPT_ENCODING=gzip, deflate
HTTP_ACCEPT_LANGUAGE=en-us
HTTP_CONNECTION=Keep-Alive
HTTP_COOKIE=afm_user_id_per_computer=afm; JSESSIONID=14AD0D44927B3B6A0071B70D52F5547F
HTTP_HOST=svr-arch.cecinc.com
HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
PATH_INFO=
QUERY_STRING=
REMOTE_ADDR=10.100.8.70
REMOTE_HOST=DTHOMPSON
REMOTE_IDENT=
REMOTE_USER=
REQUEST_METHOD=GET
SCRIPT_NAME=/arch/cgi-bin\env2.pl
SERVER_NAME=svr-arch.cecinc.com
SERVER_PORT=80
SERVER_PROTOCOL=HTTP/1.1
SERVER_SOFTWARE=TOMCAT
X_TOMCAT_SCRIPT_PATH=C:\Program Files\Afm14\Tomcat 5.0\webapps\arch\cgi-bin\env2.pl
Deb Thompson
Greenhorn

Joined: Nov 03, 2004
Posts: 5
For anyone else who has this problem, adding the line

$ENV{"SYSTEMROOT"} = "C:\\windows";

to the code fixed the problem.
K Bright
Greenhorn

Joined: Dec 01, 2004
Posts: 1
Thank you, I was having similar problems using Net::FTP. The script worked fine until I started trying to execute it as a CGI under tomcat.

from cmd prompt:
echo %SYSTEMROOT%

for me I needed to add this line to get Net::FTP to work:
$ENV{"SYSTEMROOT"} = "C:\\WINNT";

How did you know this would be the fix?
Deb Thompson
Greenhorn

Joined: Nov 03, 2004
Posts: 5
It was a strange journey. I searched the web for 2 weeks without much success. Then I got the idea to search on the error message text, and found one obscure posting that had that line of code in it. I was ready to try anything at that point, and it worked. Sometimes tenacity wins over skill!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CGI client cannot contact web