Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Error with CGI on Tomcat

Posted by sdeshpan (sdeshpan), 30 August 2007
With respect to the following link:

http://www.wellho.net/forum/Perl-Programming/Running-Perl-CGI-scripts-under-Apache-Tomcat.html

I am trying to set up tomcat 5.0.27 in this same way to execute CGI scripts. But when I am trying to the run the sample script given in this post, it gives the following error:

Code:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
     at java.lang.String.substring(String.java:1444)
     at java.lang.String.substring(String.java:1411)
     at org.apache.catalina.servlets.CGIServlet$CGIEnvironment.findCGI(CGIServlet.java:895)
     at org.apache.catalina.servlets.CGIServlet$CGIEnvironment.setCGIEnvironment(CGIServlet.java:958)
     at org.apache.catalina.servlets.CGIServlet$CGIEnvironment.<init>(CGIServlet.java:739)
     at org.apache.catalina.servlets.CGIServlet.doGet(CGIServlet.java:587)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
     at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
     at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
     at java.lang.Thread.run(Thread.java:534)




Can anyone plese help me figure out what;s wrong?

Thanks,
SD

Posted by admin (Graham Ellis), 31 August 2007
Not the most obvious of error message, is it?  If you have followed all the rest, then I wonder what your underling OS is / is the Perl binary where the script says it should be, and the very first line the #! line - even a blank line ahead of it will cause a problem!

Posted by sdeshpan (sdeshpan), 31 August 2007
on 08/31/07 at 12:38:40, Graham Ellis wrote:
Not the most obvious of error message, is it?  If you have followed all the rest, then I wonder what your underling OS is / is the Perl binary where the script says it should be, and the very first line the #! line - even a blank line ahead of it will cause a problem!

Graham,

I am running Tomcat 5.0.27 on a Windows XP Prof. machine. This is just a test setup to see of CGI works ok with Tomcat. Also, I am using the default CGI support JAR that comes with this version of tomcat. I followed all steps as is from the other forum post. I also checked for white spaces, I think we are ok there.

Any help is greatly appreciated!


Posted by admin (Graham Ellis), 31 August 2007
If it's on Windows XP, I think you'll need to change the #! line ... even though Windows doesn't usually rely on that line but rather a file extension, I think it does within the CGI standard.

Posted by KevinAD (KevinAD), 1 September 2007
on 08/31/07 at 23:45:01, Graham Ellis wrote:
If it's on Windows XP, I think you'll need to change the #! line ... even though Windows doesn't usually rely on that line but rather a file extension, I think it does within the CGI standard.


It depends on the server and the sever setup. For example, apache on windows can be setup to use the shebang  line (default setting) or not. But I have no experience with Tomcat so can't speak directly to the problem in this case. But the shebang line on windows is typically:

#!c:\perl\bin\perl.exe

or if perl is in the command path:

#!perl


Posted by sdeshpan (sdeshpan), 6 September 2007
I figured this out...It was because I didn't have ActivePerl installed (smart, innit?). Once I installed it and updated the PATH environment variable, it worked fine.

But now I am facing another issue. I am trying to execute a CGI script which connects to an Oracle DB to fetch some data. When I try to run it, I am getting the following error:

Code:
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD:: Oracle: load_file:The specified module could not be found at C:/Perl/lib/DynaLoader.pm line 229.
at (eval 7) line 3


Can anyone please help me figure out what I might be missing? I have already installed the DBD:: Oracle module for Perl.

Thanks,
Sarang


Posted by admin (Graham Ellis), 7 September 2007
on 09/06/07 at 18:58:41, sdeshpan wrote:
I figured this out...It was because I didn't have ActivePerl installed (smart, innit?). Once I installed it and updated the PATH environment variable, it worked fine.


Yeah, I guess you DO need Perl to run a Perl script ... I didn't think to suggest that one!  

Posted by KevinAD (KevinAD), 8 September 2007
on 09/06/07 at 18:58:41, sdeshpan wrote:
I figured this out...It was because I didn't have ActivePerl installed (smart, innit?). Once I installed it and updated the PATH environment variable, it worked fine.

But now I am facing another issue. I am trying to execute a CGI script which connects to an Oracle DB to fetch some data. When I try to run it, I am getting the following error:

Code:
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD:: Oracle: load_file:The specified module could not be found at C:/Perl/lib/DynaLoader.pm line 229.
at (eval 7) line 3


Can anyone please help me figure out what I might be missing? I have already installed the DBD:: Oracle module for Perl.

Thanks,
Sarang


How did you install DBD:racle? Did you use activestate perls PPM application?


Posted by sdeshpan (sdeshpan), 8 September 2007
Kevin,

You are right...I used the PPM module to install DBD:: Oracle module...I verified the installation and it says OK.

Posted by KevinAD (KevinAD), 8 September 2007
PPM is the correct way to install modules when using activestate perl. So I am not sure what the problem is. The path looks correct:

C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll

you're sure the Oracle.dll file is in the above folder?

Posted by sdeshpan (sdeshpan), 8 September 2007
Yes, I verified that the Oracle.dll file is at that location. The fact that it tries for the correction file location, looks like I have all the environment variables set properly too.

I too wonder what else might be wrong!!  

Posted by KevinAD (KevinAD), 8 September 2007
I see plenty of qestions related to Oracle on perl forums. It seems to be a bit tricky to get setup and running. Unfortunatly I have no experience with Oracle so I have no further suggestion for you.  Unless Graham has a suggestion, and his doesn't mind me posting the name of another forum, you should ask at www.perlmonks.com

Graham,

remove the reference to the other forum if that is not appropriate to post here.

Posted by admin (Graham Ellis), 8 September 2007
Quote:
Graham,

remove the reference to the other forum if that is not appropriate to post here.


Kevin - I'm perfectly happy with relevant links such as this.  

Posted by sdeshpan (sdeshpan), 10 September 2007
Thanks for all the help guys!

I was able to get past that error by a little dirty trick. I copied the OCI.dll file (and couple of other files) from ORACle_HOME/bin directory to Perl/bin and the DBD directory.

Now I seem to be going a little further where it is trying to establish a connection with the DB, but throws this error:

Code:
Error ORA-12545: Connect failed because target host or object does not exist (DBD ERROR: OCIServerAttach) connecting to DBI:Oracle:host=<hostname>;sid=<sid>;port=1521


I checked the TNSNAMES file and I am able to successfully ping and tnsping to the <hostname>. I wonder what might still be missing!  



Posted by KevinAD (KevinAD), 10 September 2007
I personally have no idea. I don' t think I will be able to help you with this problem.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho