thunders has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to get Mason working under mod_perl, but having a bit of trouble with Apache::Request. I do a simple script like the following.
<html><body> %my $planet = "World"; Hello <% planet %>! </body></html>
and I get a 500 error, with the following log:
[Tue Sep 16 06:08:39 2003] [error] [client 10.0.1.159] Can't locate ob +ject method "new" via package "Apache::Request" at /usr/lib/perl5/sit +e_perl/5.8.0/i386-linux-thread-multi/Apache/Request.pm line 22.
Mason seems ok when i run it standalone
use strict; use HTML::Mason; my $interp = HTML::Mason::Interp->new(); my $comp = $interp->make_component(comp_source => <<'END'); % my $planet = "World"; Hello <% $planet %> END $interp->exec($comp);
Apparently the problem is only with Apache Request which seems to have installed fine according to cpan. Except that the test phase did return an error..
!!! no test server configured, please specify an httpd or an apxs othe +r than /usr/sbin/apxs or put either in your PATH. For example: t/TEST -httpd /path/to/bin/httpd make: *** [run_tests] Error 1 /usr/bin/make test -- NOT OK
Has anyone ever encountered anything similar with Apache::Request? I googled and found a few similar messages, but no clear cut solution to the problem. My PC runs Mandrake 9.1, which runs a seperate apache process for mod_perl, if that matters.

Replies are listed 'Best First'.
Re: Apache::Request causing Mason to fail.
by perrin (Chancellor) on Sep 16, 2003 at 14:51 UTC
    What makes you think that Apache::Request is installed correctly? Have you tried loading it directly in a mod_perl script or Mason component?
      It had an OK status both when I tried to install from an RPM and when I tried it through CPAN and from source. I erased the RPM install, as it just gave the same error. I would say you are right, it seems pretty clear it's not installed correctly, but how else can a module be installed? I tried building Apache::Test and libapreq manually. both appeared to install, but the test of libapreq did fail again.
      [root@iweb libapreq-1.2]# make test make[1]: Entering directory `/root/.cpan/build/libapreq-1.2/c' make[1]: Leaving directory `/root/.cpan/build/libapreq-1.2/c' make[1]: Entering directory `/root/.cpan/build/libapreq-1.2/Request' make[1]: Leaving directory `/root/.cpan/build/libapreq-1.2/Request' make[1]: Entering directory `/root/.cpan/build/libapreq-1.2/Cookie' make[1]: Leaving directory `/root/.cpan/build/libapreq-1.2/Cookie' /usr/bin/perl5.8.0 -Iblib/arch -Iblib/lib \ t/TEST -clean *** setting ulimit to allow core files ulimit -c unlimited; t/TEST -clean APACHE_USER= APACHE_GROUP= APACHE_PORT= APACHE= APXS= \ /usr/bin/perl5.8.0 -Iblib/arch -Iblib/lib \ t/TEST -verbose=0 *** setting ulimit to allow core files ulimit -c unlimited; t/TEST -verbose=0 *** root mode: changing the fs ownership to 'nobody' (65534:65534) /usr/sbin/httpd-perl -d /root/.cpan/build/libapreq-1.2/t -f /root/.cp +an/build/libapreq-1.2/t/conf/httpd.conf -DAPACHE2 -DPERL_USEITHREADS using Apache-AdvancedExtranetServer/1.3.27 waiting for server to start: .Syntax error on line 116 of /root/.cpan/ +build/libapreq-1.2/t/conf/httpd.conf: Invalid command 'PerlSwitches', perhaps mis-spelled or defined by a mo +dule not included in the server configuration !!! server has died with status 255 (t/logs/error_log wasn't created, star +t the server in the debug mode) make: *** [run_tests] Error 143
        For what it is worth, i use Apache Toolbox to configure, make, and install both Apache and mod_perl. Once Apache has been installed (with the Perl interpreter inside), i use the CPAN.pm cpan shell to install all CPAN modules. The important thing is that the version of Perl you embed into Apache is the same one your CPAN modules are being installed "to". I believe that you can see if you are using one or two different Perl interpreters by inspecting the contents of @INC
        1. in a shell owned by you
        2. in a regular CGI script (via browser)
        3. in a mod_perl handler (via browser)
        Hope this helps, these problems are never fun. :/

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
        PerlSwitches is a mod_perl 2 thing. It looks like Apache::Test doesn't know what to do with the modified mod_perl and apache that Mandrake gave you. I'd suggest you build them yourself instead.

        The Apache::Test issues may be fixable. You can get help with Apache::Test on the mod_perl mailing list.

Re: Apache::Request causing Mason to fail.
by thunders (Priest) on Sep 16, 2003 at 21:48 UTC

    Well I discovered the source of the error and, it's pretty dumb on my part. But maybe someone will ask this question again so here goes...

    Mandrake runs two Apache servers at once, a regular one on port 80, and a mod_perl enabled one on port 8200.

    To use mod_perl dependent programs i'd need to call the script as http://hostname:8200/test.mhtml with my original config, or alternatively configure it under /var/www/perl which is set up to automatically calls the mod_perl enabled httpd-perl at http://hostname/perl/mason/test.mhtml

    I used this config in commonhttpd.conf

    <IfModule mod_perl.c> AddType text/html .mhtml PerlSetVar MasonCompRoot /var/www/perl/mason PerlSetVar MasonDataDir /var/www/mason-data <FilesMatch "\.mhtml$"> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler </FilesMatch> </IfModule>
Re: Apache::Request causing Mason to fail.
by Anonymous Monk on Sep 16, 2003 at 15:15 UTC
    You are not having trouble with "Apache::Request". Either your did not install mod_perl correctly (see the manual), or you did not configure mason/mod_perl correctly (once again, see the manual).

      All of the errors come from trying to work with Apache::Request, I have another application on the server that uses mod_perl and works fine.

      I did not install mod_perl at all. I am using a Linux distribution that comes with mod_perl. I did not install everything from source because I'd really rather not if I can avoid it.

      Update: Above poster is correct I misconfigured Mason. See Explaination below