Dear Monks,
I have a CGI::Application based webapp that runs fine as a normal cgi-bin script, but I'm trying to evolve it into a mod_perl handler for performance reasons.
I'm using the following environment:
Apache 2.0.59 (Unix)
mod_perl 2.0.3
perl 5.8.5
Red Hat Enterprise Linux version 4
All perl modules listed below refer to the latest versions
currently on CPAN.
You can assume that I restart the web server after any edits.
What follows is the smallest example I can write to reproduce the problem:
In my apache config file, I have the following:package MyApp::Small; use base 'CGI::Application'; #use CGI::Application::Plugin::Apache qw(:all); # Note#3 use strict; use Apache2::RequestRec (); use Apache2::RequestIO (); use Apache2::RequestUtil (); #use CGI::Application::Plugin::Session; # Note#1 #use CGI::Application::Plugin::Authentication; # Note#2 use Apache2::Const -compile => qw(OK); sub handler : method { my ($pkg, $r) = @_; my $self = $pkg->new(); $self->run(); return Apache2::Const::OK; } sub setup { my $self = shift; $self->start_mode('mode1'); $self->run_modes( 'mode1' => 'mode1', 'mode2' => 'mode2', ); } sub mode1 { my $self = shift; my $output = "<p>This is page 1.\n"; return $output; } sub mode2 { my $self = shift; my $output = "<p>This is page 2.\n"; return $output; } 1;
<Location /small> SetHandler perl-script PerlResponseHandler MyApp::Small </Location>
So, as shown above, I can access the URL http://myhost.com/small and I see the message "This is page 1."
If I uncomment the line indicated by Note#1, everything still works.
However, if I uncomment the line indicated by Note#2, I get the following error in the apache log file:
Error executing class callback in prerun stage:
Failed to Create CGI::Session object ::
Reason: new(): failed:
query object CGI=HASH(0x841395c) does not support cookie() and param() methods:
Can't locate Apache/RequestUtil.pm in @INC
At this point, I thought the problem was with using CGI.pm behind the scenes in CGI::Session (which is used by the Authentication plugin) so I tried using the CGI::Application::Plugin::Apache module, which is supposed to allow easy migration to mod_perl. But after uncommenting the line in Note#3, I get this error:
Usage: Apache2::RequestUtil::request(classname, svr=Nullsv)
at /path/to/libs/CGI/Application/Plugin/Apache.pm line 64.
This error remains even if I go back and comment out the lines indicated by Note#1 and Note#2.
I've searched online (including the archives here) and so far have been unable to figure out where I'm going wrong.
Any help will be greatly appreciated!
Thanks!
UPDATE: As it turns out, I did not have the latest version of every module from CPAN. I had installed the latest CGI.pm under my home directory, but an older version installed previously was ahead of it in @INC, so I wasn't using the version that I thought I was. Now that I've corrected that, problems #1 and #2 have gone away.
And #3 is a known problem (thanks mpeters!).
In reply to Problem running CGI::Application under modperl2 by scorpio17
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |