You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "André Warnier (tomcat/perl)" <aw...@ice-sa.com> on 2020/06/01 07:55:24 UTC
Re: Can't locate object method "new" via package "CGI::Cookie"
On 31.05.2020 20:49, Vincent Veyron wrote:
> Hi List,
>
> I have two servers using mod_perl, both having the same modules installed and enabled; server1 got a fresh install of Debian Buster, while server2 was upgraded to Buster from Stretch.
>
> This code :
> my $cookie = CGI::Cookie->new(-name => 'session',
> -value => $session_id,
> -domain => $hostname
> ) ;
>
> generates the following error on server2 :
>
> [Sun May 31 19:54:03.053725 2020] [perl:error] [pid 30663] [client 83.113.48.133:59196] Can't locate object method "new" via package "CGI::Cookie" (perhaps you forgot to load "CGI::Cookie"?) at /home/lib/Marica/Base/login.pm line 198.\n, referer: https://marica.fr/site/abonnes/index.html
>
> It works fine if add "use CGI::Cookie" to my module.
>
> What could be the reason why it works on server1 without "use CGI::Cookie" and not on server2?
>
Hi.
Since the two systems were installed/upgraded differently ..
When I configure mod_perl on a Debian system, I usually have a "startup script" running
from within the /etc/apache2/mod_enabled/perl.conf file, e.g. via
PerlPostConfigRequire "/etc/apache2/modperl2_startup.pl"
This startup script, among other things, preloads frequently-used modules, so that they
will be loaded and available later in any Apache child/thread. Like :
...
use lib "some_path_with_proprietary_modules";
...
use ModPerl::Registry ();
use CGI ();
CGI->compile(':all');
use My::Module;
...
Maybe you forgot this on one of the systems, and not the other ?
P.S.
I also use the same startup script to log some information to the Apache error log at
startup, such as this for example :
[Sun May 31 06:25:08.054152 2020] [:error] [pid 5519] mp2-startup: EFSDIR is : /home/EFS
[Sun May 31 06:25:08.054160 2020] [:error] [pid 5519] mp2-startup: AUTHZ_GRANTED is : 1
[Sun May 31 06:25:08.054166 2020] [:error] [pid 5519] mp2-startup: AUTHZ_DENIED is : 0
[Sun May 31 06:25:08.054173 2020] [:error] [pid 5519] mp2-startup: AUTHZ_DENIED_NO_USER is : 4
[Sun May 31 06:25:08.054184 2020] [:error] [pid 5519] mp2-startup: @INC is now :
/home/EFS/lib / /etc/perl / /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 /
/usr/local/share/perl/5.20.2 / /usr/lib/x86_64-linux-gnu/perl5/5.20 / /usr/share/perl5 /
/usr/lib/x86_64-linux-gnu/perl/5.20 / /usr/share/perl/5.20 / /usr/local/lib/site_perl / .
/ /etc/apache2
precisely so that I would know what the perl module library search paths would be under
Apache when it runs.
Re: Can't locate object method "new" via package "CGI::Cookie"
Posted by Vincent Veyron <vv...@wanadoo.fr>.
On Mon, 1 Jun 2020 09:55:24 +0200
André Warnier (tomcat/perl) <aw...@ice-sa.com> wrote:
>
> PerlPostConfigRequire "/etc/apache2/modperl2_startup.pl"
>
> Maybe you forgot this on one of the systems, and not the other ?
>
You know, I grepped the hell out of my modules for an hour before posting, trying to find this "use ...' line. I can't believe I indeed forgot about the startup.pl :
ssh kimsufi_3 grep use\ /etc/apache2/startup.pl | grep CGI
use CGI::Cookie ();
ssh kimsufi_2 grep use\ /etc/apache2/startup.pl | grep CGI
#use CGI::Cookie ();
Good call André :-)
(note to self : stop working when you're obviously too tired to think, so as not to embarass yourself in public)
> I also use the same startup script to log some information to the Apache error log at
> startup, such as this for example :
> 4184 2020] [:error] [pid 5519] mp2-startup: @INC is now :
...
> precisely so that I would know what the perl module library search paths would be under
> Apache when it runs.
>
Nice, thanks for the tip.