On 09.08.2018 20:05, Louis Zipes wrote:
Oh! André, if you aren't using JMX in production, you are missing-out
on a wealth of monitoring information about your JVM(s).

OK, fine, I accept that. I was just saying "IF you don't need it in production".
So, scratch the idea of running Tomcat in a console also.
You want to run Tomcat as a Service AND use JMX.
That thus leaves the problem that there is only one set of JVM command-line 
parameters.


But rather than using the JMX protocol, I would recommend using
Tomcat's JMXProxyServlet -- a part of the Manager application. That
allows you to make JMX queries over HTTP, and you don't have to
mess-around with Java's JMX-protocol configuration and ugly (and
lacking) authentication capabilities.

Just this moment we had a mystery 'hang' with my Tomcat service in PRD that 
required a Service Restart.  If I had JMX enabled then I might have been able 
to get some more information.  We just onboarded a bunch of new users but the 
Tomcat logs themselves don't clearly show memory issues so would have been nice 
to have that extra layer of logging that JMX would have given me to see if I 
could have figured it out.

Still working on the other suggestions that people have given over the last 24 
hours on trying to get it to working.

-----Original Message-----
From: Christopher Schultz [mailto:ch...@christopherschultz.net]
Sent: Thursday, August 09, 2018 1:57 PM
To: users@tomcat.apache.org
Subject: Re: [OT] Question about setting CATALINA_OPTS when starting Tomcat 
using a Windows Service in Tomcat 7.0.54

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

André,

On 8/9/18 12:39 PM, André Warnier (tomcat) wrote:
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.

This should really not be a requirement. Launching a JVM just to parse
some XML and send a single TCP packet is kind of wasteful. The problem
is that Tomcat can't rely on any particular utility programs being
installed on the server in order to do something possibly more efficient
.


I could whip-up something using grep, curl, and plain-old sh for
example that would work on most *NIX systems, but windows users
wouldn't benefit from that kind of thing.


Understood also.
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.
So your suggestion above is indeed not usable for the 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. And that's where the problem lies currently, for the OP : if these JVM parameters contain the stanza needed to open the JMX port, then the "stop" command will try again to open the same JMX port, and fail.

Under Linux, and under Windows when running tomcat in a console, there is a 
distinction
between JAVA_OPTS (which are always used in the JVM command-line), and CATALINA_OPTS (which are only added when starting tomcat). So you could put the JMX parameters in CATALINA_OPTS, and the JVM would only open the JMX port when starting tomcat. But, currently, when running tomcat as a Windows Service, there is apparently no way to provide JVM command-line parameters which are used only at start.

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".

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.


I was very surprised to find out that Tomcat's Windows service-runner
doesn't have separate "launch parameters" versus "stop parameters"
(i.e. the equivalent of CATALINA_OPTS versus JAVA_OPTS for the
script-based service-management). I guess that's just a (another) pill
you'll have to swallow if you want to run on Windows.

Of course, one could also wonder if you really need JMX when you
run tomcat in production mode.  If this is only for testing, you
could run tomcat in a console, where you would not have the same
issue (because you would not have the wrapper with its
single-minded preset JVM options).

Oh! André, if you aren't using JMX in production, you are missing-out
on a wealth of monitoring information about your JVM(s).

But rather than using the JMX protocol, I would recommend using
Tomcat's JMXProxyServlet -- a part of the Manager application. That
allows you to make JMX queries over HTTP, and you don't have to
mess-around with Java's JMX-protocol configuration and ugly (and
lacking) authentication capabilities.

(Or you could switch to Linux ;-))

A wise choice IMHO, if you have the expertise to manage it. I wouldn't
recommend that a Windows shop just switch to Linux any time soon. But
if you have people very familiar with *NIX deployments, I would
recommend keeping Windows on desktops and leave the servers running
some kind of *NIX.

- -chris

On 09.08.2018 02:06, Daniel Savard wrote:
Le mer. 8 août 2018 à 12:08, Louis Zipes <louis.zi...@gmcr.com> a
écrit :


Hi Calder, I can successfully start up as a Windows service and
get JMX working BUT my problem is that Service doesn't stop
cleanly (just repeating that problem in case it wasn't made
clear).  It says the PORT is already in use which led me to try
to use Catalina_Opts as per the suggestions on the internet.

Port already in use: 8008; nested exception is:
java.net.BindException: Address already in use: JVM_Bind

If you were able to get JMX working and you can start AND stop
the Tomcat service cleanly, do you mind sharing me your
'scrubbed'  Java tab contents as I can seem to get the right
combination to get it to Start and Stop the service.

Thanks, Louis



Louis,

I believe you need to understand a bit more how things are
working with Java and the JVM. The -D options are pretty straight
forward for anyone knowing how you define properties to the JVM
on the command line. I already told you everything you need to
know to setup properly your Tomcat. Since you were the one
talking about CATALINA_OPTS I assumed you did know where and how
to setup the variable for your installation. Otherwise, just go
in the setup utility for Tomcat on Windows and put the
-Dcom.sun.management.conf.file=${catalina.base}/conf/abc.def
entry there without the CATALINA_OPTS= stanza since this one's
intent is to set an environment variable for the process to pick
while the former is passing directly the property to the JVM from
the Tomcat Windows Setup dialog. There is many ways to do things.
Bottom line, you need to tell the JVM where is the configuration
file for JMX and put your properties in there as any other
properties file. This is standard stuff.

The effect is the JVM now knows your port is a JMX port and it
will stop to try to use it when it is already in use and free it
cleanly.

Regards,

----------------- Daniel Savard







---------------------------------------------------------------------


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

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

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAltsgHgACgkQHPApP6U8
pFg61BAAo+n7gJkweUGuLJK7Vld1n40tj2Pl4M8qS6dWs5RD250kZwNQfDCuB0h5
gjo8Uc0QjAaNchzo6kS8UUz1YqKP/MdqmLDkEzbR05saq+ge8fO45xpaSEjn1s2v
QP9aNc/M58TntaEJf5AVTqGMi+UdNWtWT9/InTjp5wixVYWpHSV6WTnFjlkw6YYs
xGSQc2C5J6tNDmEnPDzx1c61ZA/ukR6WmwA+7+Z9KGxPbmdj/qBw2NBt9Pt3OlRr
FMotxC2O9bXkjSwAWzFEcjzPeWnQYQoGmi872eiRKzBiozIjmU15MmeF12JU/f41
quS6RFeD65uxTy4y6bIQhSX1HN4at18UC+n7ts9xbGKr/nZ6glDYIvPlTiYBEJeK
763SZrTtFLylXJp7x+0Qj7EAvzcduKmuFModHYskv5tnARlBIsOEv8v2ZEJDBpS/
Jm8DjdEmZ1m63Ujf+TCZdkQyWv5cxV9u8YaZLrL+2A/EsO40GJyj2EoQp+kUMFZu
TtUBkNgWHGuiFVl6U5cddkQoUXoloLSeHTTvsnPaDRMqU74ASZlCf40j97jTH0g0
LuTWPH0CaBtok60bgYDmkv17AbsyY2dSfyXyD/+0XfbiaK6dnIrE857sxjcpk0nd
qhmopUIqAHYxFSpLtWMqFI7xboNMFvmpk0ru63H1m7eqLDFyYCI=
=sWUp
-----END PGP SIGNATURE-----

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

---------------------------------------
CONFIDENTIALITY NOTICE: This message is for intended addressee(s) only and may 
contain information that is confidential, proprietary or exempt from 
disclosure. If you are not the intended recipient, please contact the sender 
immediately. Unauthorized use or distribution is prohibited and may be unlawful.

---------------------------------------------------------------------
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

Reply via email to