Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread André Warnier

Francis GALIEGUE wrote:

On Wed, Oct 19, 2011 at 11:56, Mikolaj Rydzewski  wrote:

On Wed, 19 Oct 2011 11:42:36 +0200, Francis GALIEGUE wrote:


Extract from the script (note that the server port is not randomized,
it should probably be):

Hi all,

Why do you want to go into such deep details, like checking for particular
ports to be opened?

I have httpd, mod_proxy_ajp and tomcat. mod_proxy will catch running tomcat
after some time. It's a matter of proper configuration how long will it
take.

I guess that we all know tools like Nagios. I prefer to use them to detect
problems instead of hacking startup scripts.



Well, this is not an option for me since my sites display a static
page as long as long as the webapp is not ready. As the apps I manage
take 10 seconds to start in the best of scenarios, I need to know that
tomcat is _really_ ready to serve requests.



I think that the point which Mikolaj is making, is that there must be "retry" options in 
mod_proxy_ajp, which could avoid the kind of issue which the OP mentioned in the first place.
I just don't know these options, and they may have additional side effects.  That's why I 
originally suggested a simple wait, and Francis suggested a better way, for the specific 
issue of the OP.



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread Francis GALIEGUE
On Wed, Oct 19, 2011 at 11:56, Mikolaj Rydzewski  wrote:
> On Wed, 19 Oct 2011 11:42:36 +0200, Francis GALIEGUE wrote:
>
>> Extract from the script (note that the server port is not randomized,
>> it should probably be):
>
> Hi all,
>
> Why do you want to go into such deep details, like checking for particular
> ports to be opened?
>
> I have httpd, mod_proxy_ajp and tomcat. mod_proxy will catch running tomcat
> after some time. It's a matter of proper configuration how long will it
> take.
>
> I guess that we all know tools like Nagios. I prefer to use them to detect
> problems instead of hacking startup scripts.
>

Well, this is not an option for me since my sites display a static
page as long as long as the webapp is not ready. As the apps I manage
take 10 seconds to start in the best of scenarios, I need to know that
tomcat is _really_ ready to serve requests.

-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
f...@one2team.com
40 avenue Raymond Poincaré
75116 Paris

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread Mikolaj Rydzewski

On Wed, 19 Oct 2011 11:42:36 +0200, Francis GALIEGUE wrote:


Extract from the script (note that the server port is not randomized,
it should probably be):


Hi all,

Why do you want to go into such deep details, like checking for 
particular ports to be opened?


I have httpd, mod_proxy_ajp and tomcat. mod_proxy will catch running 
tomcat after some time. It's a matter of proper configuration how long 
will it take.


I guess that we all know tools like Nagios. I prefer to use them to 
detect problems instead of hacking startup scripts.


--
Mikolaj Rydzewski 

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread Francis GALIEGUE
On Wed, Oct 19, 2011 at 11:47, André Warnier  wrote:
> Francis GALIEGUE wrote:
>>
>> On Wed, Oct 19, 2011 at 11:42, Francis GALIEGUE  wrote:
>> [...]
>>>
>>>               lsof -u $TOMCAT_USER -i tcp:8005 &>/dev/null
>>>
>>
>> Sorry, that's a non working version: forget the -u option. But with
>> only the -i, it works.
>>
>
> Thanks, very useful. I'll try that.
>

Actually, I've discovered that there's a -a option... You can do lsof
-u $TOMCAT_USER -a -i tcp:8005.

-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
f...@one2team.com
40 avenue Raymond Poincaré
75116 Paris

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread André Warnier

Francis GALIEGUE wrote:

On Wed, Oct 19, 2011 at 11:42, Francis GALIEGUE  wrote:
[...]

   lsof -u $TOMCAT_USER -i tcp:8005 &>/dev/null



Sorry, that's a non working version: forget the -u option. But with
only the -i, it works.



Thanks, very useful. I'll try that.


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread Francis GALIEGUE
On Wed, Oct 19, 2011 at 11:42, Francis GALIEGUE  wrote:
[...]
>
>                lsof -u $TOMCAT_USER -i tcp:8005 &>/dev/null
>

Sorry, that's a non working version: forget the -u option. But with
only the -i, it works.

-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
f...@one2team.com
40 avenue Raymond Poincaré
75116 Paris

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread Francis GALIEGUE
On Wed, Oct 19, 2011 at 11:27, André Warnier  wrote:
> Francis GALIEGUE wrote:
[...]
>
> Yes, that would be more reliable than my 2 seconds above.
> Although if one really wanted to split hairs in 4 parts (lenghtwise), one
> could argue that the fact that the port mentioned in  is open and
> listening, does not necessarily mean that the port in the AJP Connector is
> open and listening.
>

Actually yes, it does mean that, I have double checked: connectors
start to listen before the Server port starts to listen.

> Now just by curiosity, what mechanism do you use exactly to check that the
>  port is listening ?  (yes, the script lines..)
>

Extract from the script (note that the server port is not randomized,
it should probably be):


   MAXITERS=120
ITERS=0

while true; do
ITERS=$((ITERS+1))
if [ $ITERS -gt $MAXITERS ]; then
echo
echo >&2 "BUG: Tomcat not started after
$MAXITERS seconds!"
exit 1
fi

lsof -u $TOMCAT_USER -i tcp:8005 &>/dev/null

if [ "$?" = "0" ]; then
break
fi
echo -n .
sleep 1
done

echo " Done (in $ITERS seconds)"


-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
f...@one2team.com
40 avenue Raymond Poincaré
75116 Paris

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread André Warnier

Francis GALIEGUE wrote:

On Wed, Oct 19, 2011 at 10:48, André Warnier  wrote:

Hi.

The problem can also be due just to the difference in startup time between
Apache httpd and Tomcat.  At the time Apache httpd (and its embedded
mod_proxy_ajp module) try to contact Tomcat, Tomcat has possibly not yet
"opened" its Connector on port 8009, which causes the host to refuse a
connection to that port.

In my experience anything involving Java tends to take a while to "start the
machinery" (it is after all a "java virtual machine").
In the practice thus, what we always do in such configurations, is to start
Tomcat first (which really means mostly "start the java virtual machine
which runs Tomcat")
, wait a couple of seconds, and then start the Apache httpd part.



Actually, there is a reliable way of waiting for Tomcat to be fully
started: wait to see the port specified in  open for
listening. Then you are sure Tomcat is fully loaded. This is what I
use and it's very reliable.



Yes, that would be more reliable than my 2 seconds above.
Although if one really wanted to split hairs in 4 parts (lenghtwise), one could argue that 
the fact that the port mentioned in  is open and listening, does not necessarily 
mean that the port in the AJP Connector is open and listening.


Now just by curiosity, what mechanism do you use exactly to check that the  port 
is listening ?  (yes, the script lines..)





-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread Francis GALIEGUE
On Wed, Oct 19, 2011 at 10:48, André Warnier  wrote:
> Hi.
>
> The problem can also be due just to the difference in startup time between
> Apache httpd and Tomcat.  At the time Apache httpd (and its embedded
> mod_proxy_ajp module) try to contact Tomcat, Tomcat has possibly not yet
> "opened" its Connector on port 8009, which causes the host to refuse a
> connection to that port.
>
> In my experience anything involving Java tends to take a while to "start the
> machinery" (it is after all a "java virtual machine").
> In the practice thus, what we always do in such configurations, is to start
> Tomcat first (which really means mostly "start the java virtual machine
> which runs Tomcat")
> , wait a couple of seconds, and then start the Apache httpd part.
>

Actually, there is a reliable way of waiting for Tomcat to be fully
started: wait to see the port specified in  open for
listening. Then you are sure Tomcat is fully loaded. This is what I
use and it's very reliable.

-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
f...@one2team.com
40 avenue Raymond Poincaré
75116 Paris

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread André Warnier

Hi.

The problem can also be due just to the difference in startup time between Apache httpd 
and Tomcat.  At the time Apache httpd (and its embedded mod_proxy_ajp module) try to 
contact Tomcat, Tomcat has possibly not yet "opened" its Connector on port 8009, which 
causes the host to refuse a connection to that port.


In my experience anything involving Java tends to take a while to "start the machinery" 
(it is after all a "java virtual machine").
In the practice thus, what we always do in such configurations, is to start Tomcat first 
(which really means mostly "start the java virtual machine which runs Tomcat")

, wait a couple of seconds, and then start the Apache httpd part.




Joe Hansen wrote:

I uninstalled Tomcat and installed a newer version (6.0.33) and the problem
disappeared. It is strange because the config files are the same.

On Wed, Oct 19, 2011 at 2:16 AM,  wrote:


Hi

I get the following AJP errors when I try to access a webpage after

ztarting

Apache and Tomcat. Both Apache web server and Tomcat start up fine
but I get these errors in Apache logs and I get a 503 Service
Temporarily Unavailable message in the browser. Apparently Tomcat
isn't seeing the request.

[error] (OS 10061) No connection could be made because the target machine
actively refused it.  : proxy: AJP: attempt to connect to
127.0.0.1:8009(localhost) failed
[error] ap_proxy_connect_backend disabling worker for (localhost)
[error] proxy: AJP: failed to make connection to backend: localhost

Can you please help me find out where the problem lies.


Have you checked the port is listening? (netstat -an) and the firewall
permits the connection (telnet localhost 8009)

John

--
/(bb|[^b]{2})/


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org







-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread Joe Hansen
I uninstalled Tomcat and installed a newer version (6.0.33) and the problem
disappeared. It is strange because the config files are the same.

On Wed, Oct 19, 2011 at 2:16 AM,  wrote:

> Hi
> >
> > I get the following AJP errors when I try to access a webpage after
> ztarting
> > Apache and Tomcat. Both Apache web server and Tomcat start up fine
> > but I get these errors in Apache logs and I get a 503 Service
> > Temporarily Unavailable message in the browser. Apparently Tomcat
> > isn't seeing the request.
> >
> > [error] (OS 10061) No connection could be made because the target machine
> > actively refused it.  : proxy: AJP: attempt to connect to
> > 127.0.0.1:8009(localhost) failed
> > [error] ap_proxy_connect_backend disabling worker for (localhost)
> > [error] proxy: AJP: failed to make connection to backend: localhost
> >
> > Can you please help me find out where the problem lies.
> >
> Have you checked the port is listening? (netstat -an) and the firewall
> permits the connection (telnet localhost 8009)
>
> John
>
> --
> /(bb|[^b]{2})/
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: AJP Errors. Apache + Tomcat

2011-10-19 Thread john
Hi
> 
> I get the following AJP errors when I try to access a webpage after 
ztarting
> Apache and Tomcat. Both Apache web server and Tomcat start up fine 
> but I get these errors in Apache logs and I get a 503 Service 
> Temporarily Unavailable message in the browser. Apparently Tomcat 
> isn't seeing the request.
> 
> [error] (OS 10061) No connection could be made because the target machine
> actively refused it.  : proxy: AJP: attempt to connect to
> 127.0.0.1:8009(localhost) failed
> [error] ap_proxy_connect_backend disabling worker for (localhost)
> [error] proxy: AJP: failed to make connection to backend: localhost
> 
> Can you please help me find out where the problem lies.
> 
Have you checked the port is listening? (netstat -an) and the firewall 
permits the connection (telnet localhost 8009)

John

--
/(bb|[^b]{2})/


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



AJP Errors. Apache + Tomcat

2011-10-19 Thread Joe Hansen
Hi,

I get the following AJP errors when I try to access a webpage after starting
Apache and Tomcat. Both Apache web server and Tomcat start up fine but I get
these errors in Apache logs and I get a 503 Service Temporarily Unavailable
message in the browser. Apparently Tomcat isn't seeing the request.

[error] (OS 10061) No connection could be made because the target machine
actively refused it.  : proxy: AJP: attempt to connect to
127.0.0.1:8009(localhost) failed
[error] ap_proxy_connect_backend disabling worker for (localhost)
[error] proxy: AJP: failed to make connection to backend: localhost

Can you please help me find out where the problem lies.

Thanks,
Joe

Environment: Apache 2.2, Tomcat 6.0.29, JDK 6, Windows 7 64-bit

/* excerpt from httpd.conf */
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

NameVirtualHost *:80


ServerAdmin a...@gmail.com
ServerName abc.local
ServerAlias www.abc.local
ErrorLog "logs/ajp.error.log"
 RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc.local [nc]
RewriteRule ^(.*)$ http://www.abclocal$1 [r=301,L]
 
AddDefaultCharset Off
Order deny,allow
Allow from all


ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/



/* excerpt from tomcat/conf/server.xml */