Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Mod_Perl2: Cannot resolve handler

by cfreak (Chaplain)
on Oct 30, 2005 at 15:20 UTC ( [id://504002]=perlquestion: print w/replies, xml ) Need Help??

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

Hello all. Having just figured out Mod_Perl1 recently I've decided to try my hand at Mod_Perl2. I think I understand the changes and I've been able to get scripts to work under ModPerl::Registry, but now I'm trying to write a custom handler and I'm not having much luck.

Everytime I try to access my handler from the browser I get a blank screen. In the log I get 'failed to resolve handler: My::Handler'. Searching around I found this typically happens when Apache can't find the module, however in all the examples I found online the error message in the logs said "Unable to find Whatever.pm in @INC etc etc etc ...". I tried intentionally breaking the path to my lib and indeed I got the rest of the error message. But when the path is correct (and a test of the syntax shows its correct too) I keep getting the error. I'm not sure where else to look.

Here's the handler code:

#!/usr/bin/perl use strict; use Apache2::RequestRec (); use Apache2::Const qw(:common); sub handler { my $r = shift; $r->print("Content-Type: text/plain\n\n"); $r->print('TEST!'); return OK; } 1;

Here's my Virtualhost configuration

<VirtualHost xxx.xxx.xxx.xxx:80> ServerName myhostname.org ServerAlias www.myhostname.org ServerAdmin admin@myhostname.org DocumentRoot /home/www/vhosts/host/html ErrorLog /home/www/vhosts/host/logs/error_log CustomLog /home/www/vhosts/host/logs/access_log combined ScriptAlias /cgi-bin/ /home/www/vhosts/host/cgi-bin/ UserDir disabled PerlOptions +Parent PerlConfigRequire /home/www/vhosts/host/lib/test-startup.pl PerlModule BCS::Test <Directory /home/www/vhosts/host/html> AllowOverride AuthConfig FileInfo Options Indexes FollowSymLinks Includes MultiViews Order allow,deny Allow from all </Directory> <Directory /home/www/vhosts/host/cgi-bin> AllowOverride AuthConfig Options ExecCGI Order allow,deny Allow from all </Directory> <Location /testpl> SetHandler perl-script PerlResponseHandler BCS::Test PerlOptions +ParseHeaders Options +ExecCGI </Location> </VirtualHost>

Thanks for the help!

Replies are listed 'Best First'.
Re: Mod_Perl2: Cannot resolve handler
by merlyn (Sage) on Oct 30, 2005 at 15:31 UTC
    #!/usr/bin/perl use strict; use Apache2::RequestRec (); use Apache2::Const qw(:common); sub handler { my $r = shift; $r->print("Content-Type: text/plain\n\n"); $r->print('TEST!'); return OK; } 1;
    Where's your package directive? You're installing "main::handler".

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

        A few more things:
        • Your module doesn't need a shebang line, although I traditionally just put "#!perl" so that emacs will go into cperl mode.
        • You don't need "Options +ExecCGI" in a URL that's not using CGI-like behavior (mod_cgi or one of the *::Registry* perl doodads).
        • You don't need "PerlOptions +ParseHeaders" unless you are planning on outputting content without a header. It also slows things down a bit.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://504002]
Approved by friedo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-25 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found