You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stephen Quinney <st...@jadevine.org.uk> on 2005/04/29 13:56:08 UTC

[mp2] Problems with Apache::Request

I've been having problems with the Apache::Request module (from
libapreq2) and mod_perl2 for a while now and I've not come up with a
decent solution. I am using the Debian packages but I didn't get a
response from the maintainer so I hope someone here can enlighten me.

This is with libapreq2-2.04_03-dev and mod_perl2 1.999.21-1 but I've
had similar problems with earlier versions.

I have a very simple mod_perl handler:

package Jadevine::Hello;

use Apache2;
use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::Request ();
use Apache::Const -compile => qw(OK);

sub handler {
    my $r = shift;
    $r->content_type('text/plain');
    print "mod_perl 2.0 rocks!\n";
    return Apache::OK;
}
1;

This is loaded in the Apache config with:

   <Location /Hello>
      SetHandler perl-script
      PerlResponseHandler Jadevine::Hello
   </Location>

If I remove the "use Apache::Request" line everything works
fine. Leaving it there, or actually trying to use the methods provided
by the module give the error:

[error] [client 127.0.0.1] failed to resolve handler `Jadevine::Hello': Apache::Request: httpd must load mod_apreq.so first at /usr/lib/perl5/Apache2/Apache/Request.pm line 31.\nCompilation failed in require at /usr/local/lib/site_perl/Jadevine/Hello.pm line 5.\nBEGIN failed--compilation aborted at /usr/local/lib/site_perl/Jadevine/Hello.pm line 5.\nCompilation failed in require at (eval 3) line 3.\n

I have tried putting the "use" statements in every order imaginable
without any joy so I'm not sure what the error is trying to get me to
do to correct the problem.

I can see where the error comes from in the Apache::Request code:

    my $env = __PACKAGE__->env || '';
    if ($mod_perl::VERSION > 1.99) {
       die __PACKAGE__ . ": httpd must load mod_apreq.so first"
            if $env ne "Apache::RequestRec";
    }

For the record $env contains 'APR::Pool', not sure if this is what
should be there or not.

Any help would be much appreciated, thanks in advance,

Stephen Quinney



Re: [mp2] Problems with Apache::Request

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stephen Quinney <st...@jadevine.org.uk> writes:

> I have tried putting the "use" statements in every order imaginable
> without any joy so I'm not sure what the error is trying to get me to
> do to correct the problem.

It's a server-config issue.  You need to add a

  LoadModule apreq_module modules/mod_apreq.so


where "modules/mod_apreq.so" is the actual path to 
mod_apreq.so on your box.  I don't know how debian
has broken up our tarball, so you may need to install
some other package that provides mod_apreq.so.

I should point out that apreq-dev@ is in the process of 
releasing a newer version, and the module name has 
changed to "mod_apreq2.so".  So you'll probably have to 
deal with this problem again once debian picks up 2.05-dev.


-- 
Joe Schaefer


Re: [mp2] Problems with Apache::Request

Posted by Foo Ji-Haw <jh...@nexlabs.com>.
Let me see if I can answer this one.

Your sample code does not use Apache::Request at all. by the way, in the 
latest release of modperl RC5, Apache::Request is now renamed to 
Apache2::Request. You probably can guess why.

If you wish to use the Apache::Request object, you need to first load 
the module in httpd.conf. It should look like this:
LoadModule apreq_module bin/mod_apreq.so

If you choose to upgrade to the latest modperl, use this:
LoadModule apreq_module bin/mod_apreq2.so

Note that the path is bin/mod...Change it to modules/mod_apreq.so if 
that is where the .so file is.

As usual, reload Apache to once you have the line in.

Stephen Quinney wrote:

>I've been having problems with the Apache::Request module (from
>libapreq2) and mod_perl2 for a while now and I've not come up with a
>decent solution. I am using the Debian packages but I didn't get a
>response from the maintainer so I hope someone here can enlighten me.
>
>This is with libapreq2-2.04_03-dev and mod_perl2 1.999.21-1 but I've
>had similar problems with earlier versions.
>
>I have a very simple mod_perl handler:
>
>package Jadevine::Hello;
>
>use Apache2;
>use Apache::RequestRec ();
>use Apache::RequestIO ();
>use Apache::Request ();
>use Apache::Const -compile => qw(OK);
>
>sub handler {
>    my $r = shift;
>    $r->content_type('text/plain');
>    print "mod_perl 2.0 rocks!\n";
>    return Apache::OK;
>}
>1;
>
>This is loaded in the Apache config with:
>
>   <Location /Hello>
>      SetHandler perl-script
>      PerlResponseHandler Jadevine::Hello
>   </Location>
>
>If I remove the "use Apache::Request" line everything works
>fine. Leaving it there, or actually trying to use the methods provided
>by the module give the error:
>
>[error] [client 127.0.0.1] failed to resolve handler `Jadevine::Hello': Apache::Request: httpd must load mod_apreq.so first at /usr/lib/perl5/Apache2/Apache/Request.pm line 31.\nCompilation failed in require at /usr/local/lib/site_perl/Jadevine/Hello.pm line 5.\nBEGIN failed--compilation aborted at /usr/local/lib/site_perl/Jadevine/Hello.pm line 5.\nCompilation failed in require at (eval 3) line 3.\n
>
>I have tried putting the "use" statements in every order imaginable
>without any joy so I'm not sure what the error is trying to get me to
>do to correct the problem.
>
>I can see where the error comes from in the Apache::Request code:
>
>    my $env = __PACKAGE__->env || '';
>    if ($mod_perl::VERSION > 1.99) {
>       die __PACKAGE__ . ": httpd must load mod_apreq.so first"
>            if $env ne "Apache::RequestRec";
>    }
>
>For the record $env contains 'APR::Pool', not sure if this is what
>should be there or not.
>
>Any help would be much appreciated, thanks in advance,
>
>Stephen Quinney
>
>
>  
>

Re: [mp2] Problems with Apache::Request

Posted by Stephen Quinney <st...@jadevine.org.uk>.
On Fri, Apr 29, 2005 at 01:56:20PM -0400, Geoffrey Young wrote:
> 
> > [error] [client 127.0.0.1] failed to resolve handler `Jadevine::Hello': Apache::Request: httpd must load mod_apreq.so first
> 
> try adding
> 
>   LoadModule apreq_module modules/mod_apreq.so
> 
> in your httpd.conf.

Ah, brilliant, thanks a lot, I was wondering if I was missing
something obvious. I guess I was just expecting the module to work the
way it did in mod_perl1.

For the record, in Debian a file is provided to make the Apache2
config very simple: /etc/apache2/mods-available/apreq.load, I just
needed to symlink this into /etc/apache2/mods-enabled/, restart
Apache2 and it all works.

Stephen 



Re: [mp2] Problems with Apache::Request

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> [error] [client 127.0.0.1] failed to resolve handler `Jadevine::Hello': Apache::Request: httpd must load mod_apreq.so first

try adding

  LoadModule apreq_module modules/mod_apreq.so

in your httpd.conf.

--Geoff

Re: Problems with Apache::Request

Posted by angie ahl <an...@gmail.com>.
I'd get upgraded to MP2 1999.22 if I were you. Stas told me I should
as things changed between your version and it, this whole use Apache2
thing has gone:

http://perl.apache.org/docs/2.0/rename.html

I figured I'd have to do it eventually and things are now running smoother. 

of course, if you can't you can't.

HTH

Angie

On 4/29/05, Stephen Quinney <st...@jadevine.org.uk> wrote:
> I've been having problems with the Apache::Request module (from
> libapreq2) and mod_perl2 for a while now and I've not come up with a
> decent solution. I am using the Debian packages but I didn't get a
> response from the maintainer so I hope someone here can enlighten me.
> 
> This is with libapreq2-2.04_03-dev and mod_perl2 1.999.21-1 but I've
> had similar problems with earlier versions.
> 
> I have a very simple mod_perl handler:
> 
> package Jadevine::Hello;
> 
> use Apache2;
> use Apache::RequestRec ();
> use Apache::RequestIO ();
> use Apache::Request ();
> use Apache::Const -compile => qw(OK);
> 
> sub handler {
>     my $r = shift;
>     $r->content_type('text/plain');
>     print "mod_perl 2.0 rocks!\n";
>     return Apache::OK;
> }
> 1;
> 
> This is loaded in the Apache config with:
> 
>    <Location /Hello>
>       SetHandler perl-script
>       PerlResponseHandler Jadevine::Hello
>    </Location>
> 
> If I remove the "use Apache::Request" line everything works
> fine. Leaving it there, or actually trying to use the methods provided
> by the module give the error:
> 
> [error] [client 127.0.0.1] failed to resolve handler `Jadevine::Hello':
> Apache::Request: httpd must load mod_apreq.so first at
> /usr/lib/perl5/Apache2/Apache/Request.pm line 31.\nCompilation failed in
> require at /usr/local/lib/site_perl/Jadevine/Hello.pm line 5.\nBEGIN
> failed--compilation aborted at /usr/local/lib/site_perl/Jadevine/Hello.pm
> line 5.\nCompilation failed in require at (eval 3) line 3.\n
> 
> I have tried putting the "use" statements in every order imaginable
> without any joy so I'm not sure what the error is trying to get me to
> do to correct the problem.
> 
> I can see where the error comes from in the Apache::Request code:
> 
>     my $env = __PACKAGE__->env || '';
>     if ($mod_perl::VERSION > 1.99) {
>        die __PACKAGE__ . ": httpd must load mod_apreq.so first"
>             if $env ne "Apache::RequestRec";
>     }
> 
> For the record $env contains 'APR::Pool', not sure if this is what
> should be there or not.
> 
> Any help would be much appreciated, thanks in advance,
> 
> Stephen Quinney
> 
> 
>