Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Weird HTML::Mason error

by tomazos (Deacon)
on Aug 01, 2005 at 15:26 UTC ( [id://479925]=perlquestion: print w/replies, xml ) Need Help??

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

I'm trying to setup HTML::Mason on an apache+mod_perl server.

When I put PerlModule HTML::Mason::ApacheHandler into my apache httpd.conf, I get the following error:

$ apachectl start Syntax error on line 1024 of /home/andrew/apache/conf/httpd.conf: unknown field passed to constructor for class HTML::Mason::ExceptionCompilation fai +led in require at (eval 4) line 3. /home/andrew/apache/bin/apachectl start: httpd could not be started

Any ideas where to start looking/debugging this one?


Update: PerlModule just loads HTML::Mason::ApacheHandler at server launch. If you do not set it, and just put the following in httpd.conf as follows:

SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler

Without calling PerlModule first, it simply requires it ever time a request is processed at runtime.

In this instance, even when I do it that way it still fails with a similiar error, when it trys to load HTML::Mason::ApacheHandler:

[Mon Aug 1 10:01:09 2005] [error] unknown field \n passed to construc +tor for class HTML::Mason::ExceptionCompilation failed in require at +(eval 5) line 3.\n [Mon Aug 1 10:01:09 2005] [error] Can't locate object method "make_ah +" via package "Apache" (perhaps you forgot to load "Apache"?) at (eva +l 31) line 6.\n


Update 2: When I simply try to:

$ perl -MHTML::Mason::ApacheHandler -e '' Undefined subroutine &Apache::perl_hook called at /home/andrew/cpan/li +b/HTML/Mason/ApacheHandler.pm line 356. BEGIN failed--compilation aborted at /home/andrew/cpan/lib/HTML/Mason/ +ApacheHandler.pm line 356. Compilation failed in require. BEGIN failed--compilation aborted.

I am not sure if this is the same problem.

In any case PerlModule HTML::Mason::ApacheHandler should work. See Mason basic config via httpd.conf


Could it have to do with me recently installing and then uninstalling Perl 5.8.7 in my home directory even though the system wide configuration is 5.6.1? Longshot.

Could it have something to do with me compiling mod_perl as a DSO and not having it statically linked? Another longshot.

HTML::Mason::CGIHandler works fine.

Apache::Registry also works fine.

HTML::Mason::ApacheHandler always fails with the above weird 'unknown field' error.


Solved! You need to enabled PerlMethodHandlers when you build mod_perl. PerlMethodHandlers allow object-oriented style inheritance of apache handlers between Perl objects. HTML::Mason::ApacheHandler uses this feature.

It could have given a nicer error message than "unknown field" though.

Especially seeing as PerlMethodHandlers are disabled by default.

-Andrew.


Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com

Replies are listed 'Best First'.
Re: Weird HTML::Mason error
by davidrw (Prior) on Aug 01, 2005 at 15:34 UTC
    Where in httpd.conf did you put it? can you post the surrounding lines as well?
      I cut it down to the minimum...

      ServerType standalone ServerRoot "/home/andrew/apache" PidFile /home/andrew/apache/logs/httpd.pid ScoreBoardFile /home/andrew/apache/logs/httpd.scoreboard Timeout 300 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 15 MinSpareServers 5 MaxSpareServers 10 StartServers 5 MaxClients 150 MaxRequestsPerChild 0 LoadModule perl_module libexec/libperl.so ClearModuleList AddModule mod_so.c AddModule mod_perl.c Port 1810 User nobody Group nobody ServerAdmin andrew@tomazos.com DocumentRoot "/home/andrew/web/ikb" PerlModule HTML::Mason::ApacheHandler # <-- FAILS HERE

      The same error as original post originating from the PerlModule line.

      -Andrew.


      Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
        PerlModule is not used for setting Apache handlers; for that you need PerlHandler.

        See the example from the Mason book.

        Try using a wrapper as suggested in the Mason manual, for example:
        #!/usr/bin/perl # handler.pl package HTML::Mason; use HTML::Mason; use HTML::Mason::ApacheHandler; use strict; { package HTML::Mason::Commands; use DBI (); use CGI (); } DBI->install_driver('mysql'); CGI->compile(':standard'); my $ah = HTML::Mason::ApacheHandler->new( comp_root => '/path/to/comp/root', data_dir => '/path/to/data/dir' ); sub handler { my ($r) = @_; return $ah->handle_request($r); } 1;
        Load it from httpd.conf:
        PerlRequire /path/to/handler.pl
        Speaking of httpd.conf, here's part of yours:
        > KeepAlive On
        > ...
        > MaxClients 150
        
        You should configure apache properly for mod_perl. Generally you want keepalive turned off and maxclients set to something your server can handle based on the size of your apache children.

        --
        perl -MO=Deparse -e"u j t S n a t o e h r , e p l r a h k c r e"

Re: Weird HTML::Mason error
by GoCool (Scribe) on Aug 01, 2005 at 16:59 UTC
    HTML::Mason::ApacheHandler is not a PerlModule as far as I know, by that i mean the directive 'PerlModule' cannot be used for a response handler. It is a response handler like ModPerl::Registry.

    Use the directive - 'PerlResponseHandler HTML::Mason::ApacheHandler' in your location block instead. Something along the lines of ...

    <LocationMatch "(\.html|\.css)$">
    SetHandler perl-script
    PerlResponseHandler HTML::Mason::ApacheHandler
    </LocationMatch>

    Hope that helps.

    GoCool
Re: Weird HTML::Mason error
by GoCool (Scribe) on Aug 01, 2005 at 17:18 UTC
    Which version of Apache, Mod_Perl and Mason are you using and what platform (OS) is it running on?
      Perl 5.6.1

      mod_perl 1.29

      apache 1.3.33

      MACHTYPE=i386-slackware-linux-gnu

      (I did recently install and then uninstall perl 5.8.7 in my home directory. Could it have left overs in my local cpan archive that are causing 5.6.1 / 5.8.7 conflicts in perl somehow? Longshot.)

      -Andrew.


      Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
        Just to be sure... you have either 'use Apache2' in your startup script or 'PerlModule Apache2' in your httpd.conf right?

        The reason i say this is because the one thing that seems to be consistent in your error messages is its inability to access subs from the Apache module.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://479925]
Approved by Joost
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: (5)
As of 2024-04-16 19:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found