Re: Can't locate object method "new" via package "CGI::Cookie"

André Warnier (tomcat/perl) <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.