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

I'm trying to copy a WEB application from a Sun Spark environment to a Linux environment. I ~believe~ I have Perl, Apache2, mod_perl and Mason installed correctly but when I try some simple code using "autohandler", I get errors.

What I get is:

error: Can't locate object method "session" via package "HTML::Mas +on::Request::ApacheHandler" at /var/www/html/autohandler line 13, <DA +TA> line 225. context: ... 9: $m->clear_buffer(); 10: 11: use Time::HiRes qw(gettimeofday tv_interval); 12: my $starttime=[gettimeofday]; 13: $m->session->{title}="Web"; 14: my $url="http://xxx.xxx.xxx.xxx"; 15: $m->session->{url}=$url; 16: 17: if(!defined $m->session->{debug})

the trace for this is:

Can't locate object method "session" via package "HTML::Mason::Request +::ApacheHandler" at /var/www/html/autohandler line 13, <DATA> line 22 +5. Trace begun at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Exceptions.pm + line 129 HTML::Mason::Exceptions::rethrow_exception('Can\'t locate object metho +d "session" via package "HTML::Mason::Request::ApacheHandler" at /var +/www/html/autohandler line 13, <DATA> line 225.^J') called at /var/ww +w/html/autohandler line 13 HTML::Mason::Commands::__ANON__ at /usr/lib/perl5/site_perl/5.8.8/HTML +/Mason/Component.pm line 138 HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x +2ae3592e5c70)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/R +equest.pm line 1300 eval {...} at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm lin +e 1295 HTML::Mason::Request::comp(undef, undef, undef) called at /usr/lib/per +l5/site_perl/5.8.8/HTML/Mason/Request.pm line 484 eval {...} at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm lin +e 484 eval {...} at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm lin +e 436 HTML::Mason::Request::exec('HTML::Mason::Request::ApacheHandler=HASH(0 +x2ae35866a9d0)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/ +ApacheHandler.pm line 168 HTML::Mason::Request::ApacheHandler::exec('HTML::Mason::Request::Apach +eHandler=HASH(0x2ae35866a9d0)') called at /usr/lib/perl5/site_perl/5. +8.8/HTML/Mason/ApacheHandler.pm line 825 HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler +=HASH(0x2ae357fca7b0)', 'Apache2::RequestRec=SCALAR(0x2ae3557ca5a0)') + called at (eval 27) line 8 HTML::Mason::ApacheHandler::handler('HTML::Mason::ApacheHandler', 'Apa +che2::RequestRec=SCALAR(0x2ae3557ca5a0)') called at -e line 0 eval {...} at -e line 0

If I change the name of the autohandler file, the test html code I have works.

I'm new to Mason and this was a new Mason/mod_perl install so I ~think~ it might be a configuration parameter someplace, but I have no idea where to look. If someone can just "point" me in the right direction I would greatly appreciate it.

Replies are listed 'Best First'.
Re: Perl Apache Mason Problem
by Anonymous Monk on Aug 10, 2013 at 09:47 UTC

    If someone can just "point" me in the right direction I would greatly appreciate it.

    Figure out what $m is in autohandler versus $m in component/dhandler, and what the difference is, then study the respective documentation

    Basic debugging checklist item 4 ( Dumper )

Re: Perl Apache Mason Problem
by Anonymous Monk on Aug 10, 2013 at 19:18 UTC
Re: Perl Apache Mason Problem
by EEddieEmm (Initiate) on Aug 14, 2013 at 20:44 UTC

    OK, we can close this one. Operator error. My httpd.conf file did not have the following;

    <LocationMatch "(\.html|\.txt|\.pl)$"> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler PerlSetVar MasonArgsMethod mod_perl PerlSetVar MasonRequestClass MasonX::Request::WithApac +heSession PerlSetVar MasonSessionCookieDomain xx.xx.xx.xx.domain.com PerlSetVar MasonSessionClass Apache::Session::File PerlSetVar MasonSessionDirectory /tmp/sessions/data PerlSetVar MasonSessionLockDirectory /tmp/sessions/locks PerlSetVar MasonSessionUseCookie 1 PerlSetVar MasonSessionCookieExpires 1209600 </LocationMatch>

    We are running better.

      OK, we can close this one. Operator error. My httpd.conf file did not have the following;

      Quick, save httpd.conf in your version control with the rest of the code :)