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:

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;
In my apache config file, I have the following:
<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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.