Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Mod-jk worker not being called after calling Perl handler

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


mohitanchlia at gmail

Nov 19, 2010, 9:09 PM

Post #1 of 6 (900 views)
Permalink
Mod-jk worker not being called after calling Perl handler

I am trying to look at how handlers work so I created a very simple
perl handler that just return "OK". And I added an entry "PerlModule"
and the "PerlHandler". I also was able to build mod_perl2.so. When I
do a GET request with handler ON I see that Handler gets called but
then the call is not going further to the mod-jk worker. Can someone
please tell me what might be going on? I thought OK will continue down
the cycle.


ryan at livesite

Nov 20, 2010, 7:14 AM

Post #2 of 6 (876 views)
Permalink
Re: Mod-jk worker not being called after calling Perl handler [In reply to]

Have you tried returning Apache2::Const::DECLINED instead?
http://perl.apache.org/docs/2.0/user/handlers/intro.html#Handler_Return_Values

On 11/20/2010 12:09 AM, Mohit Anchlia wrote:
> I am trying to look at how handlers work so I created a very simple
> perl handler that just return "OK". And I added an entry "PerlModule"
> and the "PerlHandler". I also was able to build mod_perl2.so. When I
> do a GET request with handler ON I see that Handler gets called but
> then the call is not going further to the mod-jk worker. Can someone
> please tell me what might be going on? I thought OK will continue down
> the cycle.
>


aw at ice-sa

Nov 20, 2010, 9:43 AM

Post #3 of 6 (878 views)
Permalink
Re: Mod-jk worker not being called after calling Perl handler [In reply to]

Ryan Gies wrote:
> Have you tried returning Apache2::Const::DECLINED instead?
> http://perl.apache.org/docs/2.0/user/handlers/intro.html#Handler_Return_Values
>
>
> On 11/20/2010 12:09 AM, Mohit Anchlia wrote:
>> I am trying to look at how handlers work so I created a very simple
>> perl handler that just return "OK". And I added an entry "PerlModule"
>> and the "PerlHandler". I also was able to build mod_perl2.so. When I
>> do a GET request with handler ON I see that Handler gets called but
>> then the call is not going further to the mod-jk worker. Can someone
>> please tell me what might be going on? I thought OK will continue down
>> the cycle.
>>
>
>
Ryan's answer above is correct, but here is a tad more information :

After Apache has done a lot of other things already, it looks for a handler to actually
generate the response for the client.
There can only be one of those of course, because only one response can be sent to the client.
So the first response handler which is called and which responds "OK" wins : Apache will
not call another one after that.

In your case, mod_jk and mod_perl are both response handlers (and, in the case of
mod_perl, it is in fact your own handler module, which is like a sub-handler of mod_perl).
For some reason, the mod_perl handler gets called first, before mod_jk.
And it returns OK.
So Apache never calls mod_jk.

If you want mod_jk to have a go, you must thus, in your own handler, return "DECLINED".
Then Apache will try mod_jk.

By the way, mod_jk could also return DECLINED.
(For example, if you have a "JkUnMount /*.txt" directive, and the URL happens to match that.)

In that case, Apache will call the next possible response handler. If they all return
DECLINED, then finally Apache will call its own default response handler. That is the one
that will look for the requested file on the disk, and send it as a response if it finds it.

For a response handler, returning DECLINED is like saying to Apache : "well, I had a
second look at this URL, and this is definitely not for me, find someone else".
Of course, in a mod_perl handler you can cheat, that's part of the fun.
You can do something with the URL, and then still return DECLINED.
Apache will then think that you have done nothing, and call the next handler.


mohitanchlia at gmail

Nov 22, 2010, 9:53 AM

Post #4 of 6 (870 views)
Permalink
Re: Mod-jk worker not being called after calling Perl handler [In reply to]

I tried

package Apache2::Rules2;
#use lib '/home/.mohit/mod_perl-2.0.4/lib';
use Apache2::Const qw(:common);
use Apache2::RequestRec ();
use Apache2::RequestIO ();
sub handler {
my $r = shift;
#$r->content_type('text/plain');
#$r->print("mod_perl rules!\n");
return DECLINE; # We must return a status to mod_perl
}
1; # This is a perl module so we must return true to perl

But even though I am using DECLINE it doesn't continue going to
mod-jk. Handler just becomes the final destination in this case. How
can I write handler such that it continues sending request to mod-jk.

On Sat, Nov 20, 2010 at 7:14 AM, Ryan Gies <ryan [at] livesite> wrote:
> Have you tried returning Apache2::Const::DECLINED instead?
> http://perl.apache.org/docs/2.0/user/handlers/intro.html#Handler_Return_Values
>
> On 11/20/2010 12:09 AM, Mohit Anchlia wrote:
>>
>> I am trying to look at how handlers work so I created a very simple
>> perl handler that just return "OK". And I added an entry "PerlModule"
>> and the "PerlHandler". I also was able to build mod_perl2.so. When I
>> do a GET request with handler ON I see that Handler gets called but
>> then the call is not going further to the mod-jk worker. Can someone
>> please tell me what might be going on? I thought OK will continue down
>> the cycle.
>>
>
>


ryan at livesite

Nov 22, 2010, 10:18 AM

Post #5 of 6 (883 views)
Permalink
Re: Mod-jk worker not being called after calling Perl handler [In reply to]

You should be putting "use strict;" at the top of your Perl files (which
would have reported the following error)

The constant is DECLINED, not DECLINE


On 11/22/2010 12:53 PM, Mohit Anchlia wrote:
> I tried
>
> package Apache2::Rules2;
> #use lib '/home/.mohit/mod_perl-2.0.4/lib';
> use Apache2::Const qw(:common);
> use Apache2::RequestRec ();
> use Apache2::RequestIO ();
> sub handler {
> my $r = shift;
> #$r->content_type('text/plain');
> #$r->print("mod_perl rules!\n");
> return DECLINE; # We must return a status to mod_perl
> }
> 1; # This is a perl module so we must return true to perl
>
> But even though I am using DECLINE it doesn't continue going to
> mod-jk. Handler just becomes the final destination in this case. How
> can I write handler such that it continues sending request to mod-jk.
>
> On Sat, Nov 20, 2010 at 7:14 AM, Ryan Gies<ryan [at] livesite> wrote:
>
>> Have you tried returning Apache2::Const::DECLINED instead?
>> http://perl.apache.org/docs/2.0/user/handlers/intro.html#Handler_Return_Values
>>
>> On 11/20/2010 12:09 AM, Mohit Anchlia wrote:
>>
>>> I am trying to look at how handlers work so I created a very simple
>>> perl handler that just return "OK". And I added an entry "PerlModule"
>>> and the "PerlHandler". I also was able to build mod_perl2.so. When I
>>> do a GET request with handler ON I see that Handler gets called but
>>> then the call is not going further to the mod-jk worker. Can someone
>>> please tell me what might be going on? I thought OK will continue down
>>> the cycle.
>>>
>>>
>>
>>


mohitanchlia at gmail

Nov 23, 2010, 5:22 PM

Post #6 of 6 (861 views)
Permalink
Re: Mod-jk worker not being called after calling Perl handler [In reply to]

Finally I have something that seems to work. I could find only this
way of calling mod-jk after perlhandler gets called. Does it look ok?

In <VirtualHost ..

PerlModule Apache2::Rules2
SetHandler modperl
PerlHandler Apache2::Rules2
JkMount ...

----

package Apache2::Rules2;
#use lib '/home/.mohit/mod_perl-2.0.4/lib';
use strict;
use warnings;
use Apache2::Const qw(:common);
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Filter ();
use APR::Table ();


sub handler {
my $r = shift;
my $headers_in = $r->headers_in();
if ($headers_in->get("Content-Length") < 20){
$r->handler("jakarta-servlet");
return DECLINED;
}

#$r->content_type('text/plain');
#$r->print('Rules');

return OK; # We must return a status to mod_perl
}
1; # This is a perl module so we must return true to perl


On Tue, Nov 23, 2010 at 4:17 PM, Mohit Anchlia <mohitanchlia [at] gmail> wrote:
> On Tue, Nov 23, 2010 at 9:57 AM, Mohit Anchlia <mohitanchlia [at] gmail> wrote:
>> On Mon, Nov 22, 2010 at 4:14 PM, Mohit Anchlia <mohitanchlia [at] gmail> wrote:
>>> On Mon, Nov 22, 2010 at 10:18 AM, Ryan Gies <ryan [at] livesite> wrote:
>>>> You should be putting "use strict;" at the top of your Perl files (which
>>>> would have reported the following error)
>>>>
>>>> The constant is DECLINED, not DECLINE
>>>>
>>> Thanks. I now changed it to DECLINED. Now it tries to forward the
>>> request but looks like instead of forwarding it to mod-jk worker it is
>>> trying to locate document on the same server.
>>>
>>>
>>> http://ws1/bridge/e?val
>>> HTTP request sent, awaiting response... 404 Not Found
>>> 16:11:45 ERROR 404: Not Found.
>>>
>>> In access logs it says e?val not found. It's supposed to forward this
>>> request to mod_jk worker. Because bridge is a servlet in jboss app
>>> server and apache sends it using mod_jk.
>>
>> Can someone advise why it's not going to mod_jk? How do I debug this?
>
> I haven't received any advise. Meanwhile I am thinking is it possible
> to chain the handlers such that modperl calls "SetHandler
> jakarta-servlet" ? Is there a way this can be done?
>
>>
>>>>
>>>> On 11/22/2010 12:53 PM, Mohit Anchlia wrote:
>>>>>
>>>>> I tried
>>>>>
>>>>> package Apache2::Rules2;
>>>>> #use lib '/home/.mohit/mod_perl-2.0.4/lib';
>>>>> use Apache2::Const qw(:common);
>>>>> use Apache2::RequestRec ();
>>>>> use Apache2::RequestIO ();
>>>>> sub handler {
>>>>> my $r = shift;
>>>>> #$r->content_type('text/plain');
>>>>> #$r->print("mod_perl rules!\n");
>>>>> return DECLINE; # We must return a status to mod_perl
>>>>> }
>>>>> 1; # This is a perl module so we must return true to perl
>>>>>
>>>>> But even though I am using DECLINE it doesn't continue going to
>>>>> mod-jk. Handler just becomes the final destination in this case. How
>>>>> can I write handler such that it continues sending request to mod-jk.
>>>>>
>>>>> On Sat, Nov 20, 2010 at 7:14 AM, Ryan Gies<ryan [at] livesite>  wrote:
>>>>>
>>>>>>
>>>>>> Have you tried returning Apache2::Const::DECLINED instead?
>>>>>>
>>>>>> http://perl.apache.org/docs/2.0/user/handlers/intro.html#Handler_Return_Values
>>>>>>
>>>>>> On 11/20/2010 12:09 AM, Mohit Anchlia wrote:
>>>>>>
>>>>>>>
>>>>>>> I am trying to look at how handlers work so I created a very simple
>>>>>>> perl handler that just return "OK". And I added an entry "PerlModule"
>>>>>>> and the "PerlHandler". I also was able to build mod_perl2.so. When I
>>>>>>> do a GET request with handler ON I see that Handler gets called but
>>>>>>> then the call is not going further to the mod-jk worker. Can someone
>>>>>>> please tell me what might be going on? I thought OK will continue down
>>>>>>> the cycle.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>
>>
>

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.