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

Regarding my node yesterday I thought I would continue with my new problem under a new node as the old node/title doesn't even come close to covering my new question.

Has anyone ever had trouble running Apache modules in the same scope as a module you have written?
I wrote a module (you can check it out here http://www.perlmonks.org/index.pl?node_id=108408 if you like) It's complete now and runs fine on it's own, thanks to all the perlmonks who helped.
But for some reason and module I have written that is used in the same scope as any Apache module causes the Apache module to return the error 'cant locate object method "whatever" via package "Apache::Request etc."' has anyone seen this before?

It's got nothing to do with @INC or the way the module is loaded that is all correct. And I cant think of any good reason why this would happen only with Apache and not any other modules I use.

Replies are listed 'Best First'.
Re: Apache conflicts with my modules
by echo (Pilgrim) on Aug 29, 2001 at 12:56 UTC
    Since the module you're referring to isn't a mod_perl handler, I assume you have a script that uses this module, and the error is occuring in that script. An error in Apache::Request suggest that this script is running under Apache::Registry. Hard to tell what's wrong without seeing some code, but a shot in the dark: your script is shifting what it believes are command line arguments, under mod_perl this will retrieve a reference to the request object, maybe not what you expect.
      you can check the code for my module under this node. Apart from some small changes (dumb stuff like returning my $class instead of $self) it's pretty much the same.

      The script I'm calling it from is stripped back to:
      #!/usr/bin/perl -w use lib '/home/iordy/perl.iordy.net'; use strict; use iXML::TheConstruct; use Apache::Request; my $r = Apache->request; my $apr = Apache::Request->new($r); my $construct = iXML::TheConstruct->new();

      regardless of where I have 'my $r = Apache->request;' it tells me It cannot find the method "new()" under module Apache::Request;.

      now I have written stuff (1 or 2 things only; I'm new to perl) in this manner before but I have never done it with a module I have written myself (the module shown in the node listed above is my first ever attempt.)

      so I'm stumped as to why this would be happening.
        Is libapreq installed? That's where the Apache::Request object comes from. If you don't need its extended features, you can just use $r which is usually enough.

        BTW, you can write:

        my $r = shift;
        instead of
        my $r = Apache->request;
Re: Apache conflicts with my modules
by Zecho (Hermit) on Aug 29, 2001 at 12:03 UTC
    I have seen Apache balk/fail/die while loading an external module that conflicted with one of it's own modules in any way shape or form.. Dont know how you would test this theory without unloading one mod_* at a time, reloading apache and trying again. then as they say lather rinse repeat.