Re: Windows Service Weirdness

2018-08-10 Thread Suvendu Sekhar Mondal
On Sat, Aug 11, 2018, 12:33 AM Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> All,
>
> Did something change with Windows recently?
>
> On this list and on SO there seem to be lots of questions about
> "Tomcat not releasing ports".
>
> Examples:
> https://stackoverflow.com/questions/51764300/tomcat-8-does-not-release-p
> ort-80-at-restart-on-windows
> 
> https://stackoverflow.com/questions/51791717/tomcat-8-will-not-startup-o
> n-free-port
> 
> https://stackoverflow.com/questions/51773720/windows-keeping-port-locked
> - -after-shutting-down-tomcat
>
> The symptoms all seem to be the same: Tomcat starts, stops, but then
> won't restart using the same selection of ports. "netstat" shows that
> the ports are available, but launching Tomcat encounters a failure
> during port-binding.
>
> I don't have an environment in which to test this (I'm allergic to
> Windows), but I'd be interested to hear if anyone has seen anything
> like this, or if it's just very common to misconfigure Tomcat in some
> specific way (e.g. declaring two `` elements with the same
> port number).
>
> - -chris
>

Yes, Chris. Recently Microsoft released July security patches for Windows
OS. Now some of those patches are "buggy". After applying them, we started
seeing lots of TCP port conflict issues. In our case, Apache httpd as well
as Tomcats were affected. Symptoms matches what you mentioned in the mail.
netstat will show ports are free but TC will not be able to bind to it. So,
we decided to uninstall those patches and after that everything came back
to normal. Here is some details:
https://www.computerworld.com/article/3290465/microsoft-windows/stung-by-a-festering-pile-of-bugs-on-patch-tuesday-ms-releases-27-more-patches.html

To fix this issues, MS has released another set of patches. :)

Can you please ask the affected users to uninstall July security patches
and try again?

Thanks!
Suvendu

-BEGIN PGP SIGNATURE-
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
>
> iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAltt4ZIACgkQHPApP6U8
> pFh8+w//Y6UoJvFiLYLkwvJosPDLhn3TLgY+fGdpvo3KZKxTvBX2neLHRqLiJimt
> PVcc+5HipDut3Eu+bJLDPFKQSHN0WbG/IxkcUGyui2K4sUFM1WWxi1EWeHNqSNfj
> kpbIr/DnlhJSM0wVM5EH0lV0HO90UJ6tTNHPvQx03T+stuILPasmFXqoSNFCP3rC
> s9ZVk7LVltOPxPJ3tkqKLLOl2b0iaXltHXofC4GtEC/1BUEEYspxkBaCM9kOOsgl
> cWN9fGUAXgnQv+7ISStSl9BwvHk0Vf9WSaSYtPNzoQxa34CWmOls2gdUONAlIwyi
> 0ozLCHWPImR1d44DhDor6j0Uw7sQ5yFuoNs18ijcfzqdHYHqYqQ3RPGabowm8JQd
> pNvvaSGeHVEvdG2YHa0hpwLbDhchIL9/VcaQYiGHZk7HQVmbvCQ5gGGP5rKo6yPM
> E2uHEBDXdsiHuSd2rOpehc5Ysv1m0Qv6fZN4KFWMvREGb5IGtwvTzmcZr3iXw4W8
> 4Dx+TPGufKybW6W2F24Ko4xmxLYkptEyBhAd5v/XYeRHNfin9dYTAxkZnH57vMYc
> b+lWCqQlzKWqc8bhXtJvSbG8L6Mk6WtOLvRiOyz96JywES6Ald8QaOXE0siPEmws
> CQhgetCTrbSJlml7t9ahbEsOdt2LaczRmgXpdKrB6b/QAg448TM=
> =/OiR
> -END PGP SIGNATURE-
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Windows Service Weirdness

2018-08-10 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

All,

Did something change with Windows recently?

On this list and on SO there seem to be lots of questions about
"Tomcat not releasing ports".

Examples:
https://stackoverflow.com/questions/51764300/tomcat-8-does-not-release-p
ort-80-at-restart-on-windows
https://stackoverflow.com/questions/51791717/tomcat-8-will-not-startup-o
n-free-port
https://stackoverflow.com/questions/51773720/windows-keeping-port-locked
- -after-shutting-down-tomcat

The symptoms all seem to be the same: Tomcat starts, stops, but then
won't restart using the same selection of ports. "netstat" shows that
the ports are available, but launching Tomcat encounters a failure
during port-binding.

I don't have an environment in which to test this (I'm allergic to
Windows), but I'd be interested to hear if anyone has seen anything
like this, or if it's just very common to misconfigure Tomcat in some
specific way (e.g. declaring two `` elements with the same
port number).

- -chris
-BEGIN PGP SIGNATURE-
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAltt4ZIACgkQHPApP6U8
pFh8+w//Y6UoJvFiLYLkwvJosPDLhn3TLgY+fGdpvo3KZKxTvBX2neLHRqLiJimt
PVcc+5HipDut3Eu+bJLDPFKQSHN0WbG/IxkcUGyui2K4sUFM1WWxi1EWeHNqSNfj
kpbIr/DnlhJSM0wVM5EH0lV0HO90UJ6tTNHPvQx03T+stuILPasmFXqoSNFCP3rC
s9ZVk7LVltOPxPJ3tkqKLLOl2b0iaXltHXofC4GtEC/1BUEEYspxkBaCM9kOOsgl
cWN9fGUAXgnQv+7ISStSl9BwvHk0Vf9WSaSYtPNzoQxa34CWmOls2gdUONAlIwyi
0ozLCHWPImR1d44DhDor6j0Uw7sQ5yFuoNs18ijcfzqdHYHqYqQ3RPGabowm8JQd
pNvvaSGeHVEvdG2YHa0hpwLbDhchIL9/VcaQYiGHZk7HQVmbvCQ5gGGP5rKo6yPM
E2uHEBDXdsiHuSd2rOpehc5Ysv1m0Qv6fZN4KFWMvREGb5IGtwvTzmcZr3iXw4W8
4Dx+TPGufKybW6W2F24Ko4xmxLYkptEyBhAd5v/XYeRHNfin9dYTAxkZnH57vMYc
b+lWCqQlzKWqc8bhXtJvSbG8L6Mk6WtOLvRiOyz96JywES6Ald8QaOXE0siPEmws
CQhgetCTrbSJlml7t9ahbEsOdt2LaczRmgXpdKrB6b/QAg448TM=
=/OiR
-END PGP SIGNATURE-

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



RE: Question about setting CATALINA_OPTS when starting Tomcat using a Windows Service in Tomcat 7.0.54

2018-08-10 Thread Louis Zipes
Slotting this Interim update before we started using [OT] so not sure if this 
is the right spot.

>> You see the error you are see because you are using Java mode. Switch
>> to jvm mode and all should be well.

I did try with JVM mode but now I'm getting a Client Version mismatch.  I'm 
going to try to download the 64 bit version of Tomcat BUT I'm using the Tomcat 
that came pre-packaged with my application package  so I wonder if there is a 
reason why they loaded it with 32 bit

Error message on start up

[2018-08-09 08:37:59] [info]  [ 4304] Stopping service...
[2018-08-09 08:37:59] [error] [ 4304] %1 is not a valid Win32 application.
[2018-08-09 08:37:59] [error] [ 4304] Failed creating java C:\Program 
Files\Java\jdk1.7.0_80\jre\bin\server\jvm.dll
[2018-08-09 08:37:59] [error] [ 4304] %1 is not a valid Win32 application.

-Original Message-
From: André Warnier (tomcat) [mailto:a...@ice-sa.com]
Sent: Thursday, August 09, 2018 12:40 PM
To: users@tomcat.apache.org
Subject: Re: Question about setting CATALINA_OPTS when starting Tomcat using a 
Windows Service in Tomcat 7.0.54

- - - external message, proceed with caution - - -


Maybe it is time here to quote Arthur Clarke's 3rd law :
"Any sufficiently advanced technology is indistinguishable from magic"
(See : https://en.wikipedia.org/wiki/Clarke%27s_three_laws)

The process by which Tomcat is started and/or stopped - particularly under 
Windows and as
a Service - is not very clear in the on-line documentation.
Neither is it it very easy to write a comprehensive and accurate documentation, 
because
the thing has gotten to a point where, for mere mortals, it is really quite 
complicated.
(Have a look at bin/catalina.bat to get an idea).

So let me give you some overall pointers (some of them quite basic, I 
apologise), and
maybe in there somewhere, you'll find wat you are missing to complete the 
picture and do
what you want to do.

1) Tomcat is a compiled java application, in java bytecode.  To run this 
bytecode, you
need a JVM. The JVM is machine-executable code, so to run tomcat, you run a JVM 
and tell
it to run the tomcat bytecode.
2) the java JVM for Windows is not very good at running as a Windows Service 
(it does not
handle the appropriate Windows "signals" etc.). To solve this, when you want to 
run tomcat
as a Windows Service (or rather - see above - run the JVM as a Windows 
Service), you
actually run a specialised "wrapper program" which does work well as a Windows 
Service,
and you ask this wrapper to start the JVM which runs tomcat.
To make matters a bit more confusing (or maybe, for some, clearer), this 
generic "Windows
Service JVM wrapper" is renamed to "tomcatV.exe" (where V is the tomcat 
version, so for
tomcat 9, the program is called tomcat9.exe).
3) the wrapper program, when it starts the JVM, has to know which command-line 
switches it
should pass to it.  For the Windows Service flavor of tomcat, these parameters 
are stored
in a number of special keys in the Windows Registry, and that is where the 
wrapper picks
them up, before starting the JVM.
4) To make it easier to set and edit these JVM command-line parameters, tomcat 
provides
another Windows executable program - a specialised GUI Registry Editor - which 
is also
renamed according to the tomcat version, as tomcatVw.exe (where V is the tomcat 
version,
so for tomcat 9 it would be tomcat9w.exe).

5) as a separate bit of knowledge, I would suppose that everyone knows that on 
any given
host, a given TCP listening port can only be opened by one process at a time. 
If a second
process tries to open a port which is already opened by a first process, it 
will get an
error of the kind "port already in use", and most probably the second process 
will then
exit (non-gracefully).

6) in the tomcat conf/server.xml file, there is a tag :

This provides a clue as to how one actually *stops* tomcat : one opens a TCP 
connection to
locahost port 8005 (on which tomcat listens), then sends the string "SHUTDOWN" 
on that
connection. This causes tomcat to shutdown gracefully, at the end of which it 
does a
"system.exit()" which shuts down the JVM that runs it.
And this in turn causes the JVM wrapper program to tell Windows that the tomcat 
Service is
shutting down, before itself exiting. And thus is all well and tidy in the 
Windows Service
world.

7) a helpful feature of tomcat, is that it itself provides code to connect to 
localhost
port 8005 and send that shutdown string, so that one does not have to write its 
own
separate program to do that.
The bit that is a bit confusing about this feature however, is that in order to 
use that
code, one of course needs to start up another separate instance of tomcat, just 
to run
that code and actually stop the "real" running tomcat.
And of course running a separate instance of tomcat actually means running a 
separate
instance of the JVM which runs tomcat.

Now armed with all the above knowledge, and with the dialog window offered by 
the

Re: [OT] Question about setting CATALINA_OPTS when starting Tomcat using a Windows Service in Tomcat 7.0.54

2018-08-10 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

André,

On 8/9/18 6:22 PM, André Warnier (tomcat) wrote:
>> The problem remains though : Under Windows, a Service has a
>> single executable, which Windows starts when starting the
>> Service, and then waits for that executable to send back a
>> message indicating that the Service has properly started. 
>> Similarly, to stop the Service, Windows sends a message "please
>> stop" to that running executable, and waits for the executable to
>> acknowedge that it is stopping. With Tomcat, this executable is
>> "tomcatV.exe" (the renamed Apache Common wrapper). To my
>> knowledge, there is no provision in Windows for starting a
>> service by running one executable, and stopping it using
>> *another* executable.

This is true, but tomcatV.exe actually handles this correctly. But
there is a difference between "java" and "jvm" modes. Go back and read
Mark's message about it carefully, again; I had to do so myself before
I understood why it will work by switching modes.

>> So your suggestion above is indeed not usable for the Windows
>> Service context.

Correct. Even a self-contained "Tomcat-stopping win32 program"
wouldn't work in a Windows-service-context.

>> And thus, for stopping the Tomcat Service, the user is stuck
>> with tomcatV.exe, which uses the *same* JVM command-line
>> parameters whether it is to start or to stop tomcat.

Unless "jvm" mode is used.

>> A solution would be to add a separate options box to the
>> "Startup" and "Shutdown" tabs of the tomcat9w.exe dialog for
>> "additional JVM options at start" and "additional JVM options at
>> stop" (and of course all the associated plumbing in the wrapper
>> code). But I guess that this would go in the category of
>> "enhancement request".

Correct, but "jvm mode" should work with existing features.

>> I've seen Mark's previous answer, which seems to indicate that
>> there is actually another way, but I must confess that I did not
>> understand it.

If you use "java" mode, this is what happens:

Service launch:
1. Windows Service Manager invokes tomcatV.exe
2. tomcatV.exe reads registry for config
3. tomcatV.exe invokes "java [params] o.a.c.Bootstrap start"

Service shutdown:
1. Windows Service Manager invokes tomcatV.exe
2. tomcatV.exe reads registry for config
3. tomcatV.exe invokes "java [params] o.a.c.Bootstrap stop"

You see the problem because "[params]" are the same in both cases, and
the JMX port (and any other Java-specified ports, such as a profiling
agent, etc.) conflict.

If you use "jvm" mode, this is what happens:

Service launch:
1. Windows Service Manager invokes tomcatV.exe
2. tomcatV.exe reads registry for config
3. tomcatV.exe launches an in-process JVM with "[params]" and then
calls o.a.c.Bootstrap.main("start")

Service shutdown:
1. Windows Service Manager invokes tomcatV.exe
2. tomcatV.exe reads registry for config
3. tomcatV.exe calls o.a.c.Bootstrap.main("stop") on the
already-running in-process JVM

In the "jvm mode" case, only one JVM is launched for the start/stop
sequence instead of one JVM for each of start, stop.

So he port-conflict is avoided, and the system is more efficient
(launching a JVM is pretty expensive).

- -chris
-BEGIN PGP SIGNATURE-
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlttvsEACgkQHPApP6U8
pFgnThAAvZXka+FYgjiJYM+RfYoBOuAwsym44WyToFo7JAAXhMzzIDM8CY6ZceOs
ZojWLcCAYCzDjiBhuEh2KdUfnaelrUPG0451jj0cBqNe6kkSXZ4soS27t+uyUSKG
SPx8u+j5CtHsvEhC5TwwBAVe9dLZ2kD4s8y14R7o3A/sbwim7kgKOw4cA7BdrrmT
0jK4+ce6d1vv5edTkU84HnjNx4y96jbr4/uKBOa+qPYgHeYct84/ADKXn4dZcce6
lliiPu6kGWOvpu04kqqSqwVY3KrcT91q5aXJ8UYyiSbOr+cj+HP4GhDy+Dxdnoze
Kzi+9V7bqkSa9g995kED4v3mRTfg76dRjuxnHbw1hGThkCO5Pi3MJQOjaUfs1XMo
EgT/OLvRqPQlYvi3S1r36QzDBCKh1LVyDntSMIiJn0ilthrwHJfhiPRH6n9jb7Gp
egP3tb+s6LJp15uA8noyTBTBVlOwFE8Kw8XXyEtwOE7cW0QJQXpJSkbatJqsHB94
v10a37SuagkkzaJugGfey6Vcg9oGjWWjENIxB7yK2dZHm1+cm263/9Qmi37WVj4d
KWMdghzoazdOxvK5ntFi2hOs0kdQ3v+EgxWQR9FKJz73piIvsIleVE3v4B49W5oh
nTM/eJtOwJcoYdLG3ljNpND61BvpjuFCm9JUbWizFgJMu6OjY2k=
=F5zk
-END PGP SIGNATURE-

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



Re: Documentation for Catalina Base

2018-08-10 Thread Marek Czernek

Hi there,

Well this just confirms that this doc change is helping more people and 
the doc should be improved.


I have changed the path but as far as I know, the path is literally 
irrelevant. If you unzip your tomcat to D:\tmp\, that will be your 
catalina.home.


Glad this will help someone.

On 08/09/2018 05:59 PM, Lemke, Michael ST/HZA-ZIC2 wrote:

On Thursday, August 09, 2018 4:23 PM, Marek Czernek wrote:

Hi,

any thoughts about the PR anyone? [1] Feel free to suggest any
improvements, or help me better the docs with your comments of course.

[1] https://github.com/apache/tomcat/pull/117

Hi Marek,

thanks for writing this. Wish you'd done it earlier as I had the very same problem about 
two months ago (search for "Tomcat Installation on Windows" in this mailing 
list). My suggestion would be to have CATALINA_HOME reference something like C:\Program 
Files\apache-tomcat-9.0.10 on Windows. That would make it very clear that this is code 
you are not supposed to touch. But I have the feeling that tomcat isn't too strict about 
such a concept and might require you to do so anyway.

Michael



Cheers,

On 07/30/2018 09:22 AM, Marek Czernek wrote:

Hi there,

recently, we noticed the lack of documentation for Catalina Base, and
I wanted to find out more about it. Other than a strangely obscure txt
file [1], I did not find the concept and usage of Catalina Base
documented in the Tomcat docs.

My questions are:

1) Did I overlook it being documented somewhere?

2) If not, is there any reason for it not being documented? While I
don't want to duplicate text, I do not consider a txt file somewhere a
sufficient docs.

If the answer to both of my questions is no, we'll create a patch
against the Tomcat docs.


[1] https://tomcat.apache.org/tomcat-9.0-doc/RUNNING.txt


Cheers,


--

Marek Czernek

JWS/JBCS Associate Quality Engineer, RHCA

Find me at www.halfastack.com


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



--

Marek Czernek

JWS/JBCS Associate Quality Engineer, RHCA

Find me at www.halfastack.com