Tomcat catalina opts windows

Where is the “catalina.out” on Windows?

I have a tomcat on a linux machine and I can visualize the «catalina.out» file.

I wanted to migrate my development environment (Eclipse IDE, JDK 6, Tomcat 6, etc.) from linux to windows.

Everything is ok but, I cannot find the «catalina.out» on my windows tomcat !

I read this post but the solution is not suitable for the eclipse IDE (as i’m launching tomcat from eclipse).

How can I generate the «catalina.out» file in windows ?

6 Answers 6

catalina.out and other CATALINA_HOME/logs/*.log files are completely different logs.

All CATALINA_HOME/logs/catalina*.log files belongs to Tomcat server. If you don’t use Tomcat’s JULI you won’t find them really useful.

catalina.out is just a redirected output from running server. If your app is logging on console (e.g. by using ConsoleAppender in log4j) you will find your logs there.

Problem is that windows startup script doesn’t contain support for catalina.out. You won’t find e.g. parameter CATALINA_OUT. So it’s not possible to use it and you have to configure your logging library to create file by itself or fix catalina.bat. I’m not a Windows user but you should check lines like:

and put some redirections at the end

Catalina.out is not generated for windows but you can send command line tomcat output to file by editing catalina.bat or startup.bat. In startup.bat :

It is in «Tomcat folder\logs», and the name is different: catalina-2011-11-23.log, where 2011-11-23 represents the date in American format.

In the view named ‘Servers’ you should find your tomcat instance.

If you double click the server in this view a dialog opens where you can configure the server settings. Where you find catalina.out depends on the setting of ‘Server Locations’ .

If you select the option Use Tomcat installation and set the path to your TOMCAT_HOME (installation folder of tomcat) eclipse will control this instance an you will find everything on a well defined place.

Question: Where to set JAVA and CATALINA OPTS #80

Comments

StefanSchubert commented Nov 4, 2019

if have tried to configure the JAVA_OPTS via setenv.sh in
/opt/bitnami/tomecat/bin

but it seems that this changes are overwritten (i.e. destroyed through appending by the bootstrapping).

also /bitnami/tomcat/bin and .nami/registry.json doesn’t seem to work.

What it the correct place if I need to change the settings? I need to provide the tomcat with more heap space and to enable the JMX ports, so that I can fetch the vital jvm params for monitoring.

Thanks in advance
Stefan

The text was updated successfully, but these errors were encountered:

gongomgra commented Nov 5, 2019

You can set the JAVA_OPTS environment variable when running the container or set it in the docker-compose.yml file. The values you set in that environment variable won’t be concatenated with the default values, so you will need to explicitly include the default parameters as shown below

Another option is to modify the libtomcat.sh script present into the rootfs folder of the Tomcat version and OS of your choice, and customise the JAVA_OPTS environment variable in that file. After that, you will have to build your custom Tomcat docker image with your changes.

Читайте также:  Install unzip on linux

Hope it helps,
Gonzalo

StefanSchubert commented Nov 5, 2019

thanks for help. Meanwhile I found a solution (almost the same) by providing just an environment via Dockerfile, Docker-compose (of CM in k8s).

I added (as I read somewhere that this is the prefered way of customizing the settings):

CATALINA_OPTS=»-Xms256m -Xmx512m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false»

as I’m trying to enable JMX monitoring (via jmx-exporter as prometheus sidecar).
Unfortunately I wasn’t able to connect via jconsole from my host to the jmx port (still local setup yet with docker-compose).

I checked that the port 9000 is up and listening (via deriving from the image an apt-get install net-tools), however when connecting via jconsole to localhost:9000 nothing happend.

Am I missing some setting?

gongomgra commented Nov 6, 2019

How did you define the environment variable in the docker-compose.yml file? I made it work both with a docker run and docker-compose . For docker run I exactly run the next command. Note I’m manually exposing the port 9000 from the container to my computer

After that, I connected to localhost:9000 on jconsole and I can see the monitoring data.

For docker-compose I modified the file to look as below, and running docker-compose up allowed me to connect with jconsole to localhost:9000 without issues

Can you try using the docker-compose.yml file above? Find below a screenshot of jconsole connected to port 9000

StefanSchubert commented Nov 9, 2019 •

thanks a lot for supporting me.
As I build the tomcat with a war in the autodeployment, I pass the environment options directly in the docker file (and checked the tomcat logs that the settings have been drawn).

To verify that I have no other local problem, I copied your docker-compose example and tried it out.
Unfortunately either console nor visualVM is able to connect (long running connection build up until a timeout after felt 2min).

So it must be something local on my host (mac os catalina).

While the tomcat container is using:

Maybe something with my local java version? Which one are you using?
Next week I will try to fetch a collegue to verify this also on a win10 machine.

Have a nice weekend
Stefan

gongomgra commented Nov 12, 2019

I reproduced your issue on OS X. On this platform, containers are not running directly on Mac OS X but on a VM called boot2docker . Because of that, it is necessary to configure Tomcat to allow remote connections on that IP address and port 9000. You will need to add the next options to the CATALINA_OPTS variable:

Where IP address is the result of running the next command on your OS X machine after started the docker engine

So in my case, I configured Tomcat with that value and then used jconsole with that IP address as shown in the next image

Regarding the JAVA version, I used the one installed on my OS X machine, that is different than the one in the container.

Hope it helps,
Gonzalo

StefanSchubert commented Nov 12, 2019

this helps a lot! I can in fact connect now with jconsole and visualVM! Thanks a lot!

One thing I have changes from your solution was setting of,
-Djava.rmi.server.hostname=localhost

as docker-machine wasn’t working:

I guess that might have to to with the docker desktop version I’m using (it’s 2.1.0.4 community edition)

Localhost will be also fine for the prometheus-sidecar (jmxexporter) I deployed within the same POD as the tomcat in my kubernetes target cluster. I guess as the additional settings seems to be more mac specific, that the jmx-exporter could query tomcats JMX interface all the way long, since meanwhile I discovered that I also have a DNS problem in my cluster, as the prometheus target (the jmx exporter) could not be reached.

Anyway the additional settings will be kept in place, while hunting down my DNS problem.
What I find confusing is that you need to announce the port twice for jmxremote:

Читайте также:  Разделение жестких дисков при установке windows

Which seems to be odd. Even more odd I found, that not many people seems to have the same problem, as I did not found a page explaining the differnce — or I’m using the wrong keywords with google.

StefanSchubert commented Nov 12, 2019

One additional thing, I just grasped from: Oracle-Docs

The default rmi.server.hostname is in a dotted format! And at home I’m behind a DS-lite connection, meaning my host is in the ipv6 universe and has not dotted IP adress of the ipv4 realm. I’m sure that’s one of the thing causes the observed problems. HY S*T I’m still not used to it. I need consider to post a JSR for java being fully compliant with ipv6, too.

If I understood the page right (as english is not my native language),

is required If you want to allow this port reachable from localhost (meaning listening on the local adapter), too. While

is required if you want JMX to listen on real remote connections.

Hm — for what reasons did they need to distinguish here?

rafariossaa commented Nov 13, 2019

Hi @StefanSchubert ,
Setting both parameters to the same port looks strange, but it is possible and it saves you to open a new port.
It is not easy to find information on this kind of configuration, I am not a java developer, but my guess is that configuration is mostly used in local to debug tomcat applications.
About the need of using two ports, it seems that one is used for manage the connections and the other is for transferring data among the stubs. Maybe in a java forum can give you a better answer to this question.

stale bot commented Nov 28, 2019

This Issue has been automatically marked as «stale» because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

stale bot commented Dec 3, 2019

Due to the lack of activity in the last 5 days since it was marked as «stale», we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

CATALINA_OPTS vs JAVA_OPTS — What is the difference?

I was trying to find out the difference between Apache Tomcat variables — CATALINA_OPTS and JAVA_OPTS in SO and surprised to see that there is no question/answer posted here yet. So I thought of sharing it here (with answer) after finding out the difference. Check the answer/difference below.

NOTE: At the time of this posting, we’re running Apache Tomcat v6.0.10 with JDK 6u32 on CentOS5 64-bit arch.

2 Answers 2

There are two environment variables — CATALINA_OPTS and JAVA_OPTS — which are both used in the catalina.sh startup and shutdown script for Tomcat. They are described in comments within that file as:

[JAVA_OPTS]: (optional) Java runtime options used when the «start», «stop» or «run» command is executed

[CATALINA_OPTS]: (optional) Java runtime options used when the «start» or «run» command is executed

So why are there two different variables? And what’s the difference?

Firstly, anything specified in EITHER variable is passed, identically, to the command that starts up Tomcat — the «start» or «run» command — but only values set in JAVA_OPTS are passed to the «stop» command. That probably doesn’t make any difference to how Tomcat runs in practise as it only effects the end of a run, not the start.

Читайте также:  Драйвер для веб камеры genius messenger 310 для windows 10

The second difference is more subtle. Other applications may also use JAVA_OPTS, but only Tomcat will use CATALINA_OPTS. So if you’re setting environment variables for use only by Tomcat, you’ll be best advised to use CATALINA_OPTS, whereas if you’re setting environment variables to be used by other java applications as well, such as by JBoss, you should put your settings in JAVA_OPTS.

tomcat – коротко для windows

С сайта http://tomcat.apache.org сохраняем zip-архив, и распаковываем его в папку с путём без пробелов и всяких сложных символов, например, «E:\tomcat\apache-tomcat-8.0.15».

Скачиваем последнюю версию JDK с сайта оракл https://www.oracle.com и ставим её тоже в папку с названием без пробелов (если так не сделать, и установить в папку X:\Program Files\. , то затем, когда мы будем править батник, нам придётся неявно указывать имя папки, это не очень хорошо, почему- будет видно дальше.

Открываем «e:\tomcat\apache-tomcat-8.0.15\bin\». Видим много батников и sh сценариев.

Открываем «catalina.bat». Там видим много закомментированных строк с переменными окружения, которые должны быть объявлены, или которые можно объявлять, а можно и нет.

Те переменные, которые должны быть объявлены — это

  • set CATALINA_HOME=»e:\tomcat\apache-tomcat-8.0.15″
  • set JAVA_HOME=»e:\ProgramFiles\Java\jre1.8.0_25″

причём желательно это сделать в отдельном файле с именем setenv.bat, для этого просто в текстовом редакторе вбиваем эти две строки и сохраняем файл с таким именем в «e:\tomcat\apache-tomcat-8.0.15\bin\»

Примечание: если папка с установленным jre содержит пробелы, то имя должно состоять из максимум шести первых букв реального названия папки, и если такое сочетание по алфавиту в диске первое, то

1, если второе, то

Например, название папки, внутри которой находится jre, “C:\Program Files\JRE”, а кроме того есть папка «C:\places\», тогда вторая строчка в setenv.bat будет

1\Java\jre1.8.0_25″, или
set JAVA_HOME=»e:\P

Естественно, это не очень хорошо, особенно когда у вас две папки “Program Files” и «Program Files (x86)». В таком случае, чтобы проименовать правильно папку с JRE, придётся поэкспериментировать

Пробуем запустить, для этого из текущей директории запускаем cmd.exe, в нём запускаем startup.bat . Это нам даст контроль над тем что происходит. Если всё пошло хорошо, то запустится окно Java-приложения в режиме консоли, в котором после запуска будет написано время старта, если же что-то пошло не так, например, папки в setenv.bat указаны неверно, мы увидим сообщения об ошибках.

Если глобальные переменные сконфигурированы верно, и запустилось окно java – консоли, но какие-то настройки сделаны неверно, то ошибки можно посмотреть в папке «e:\tomcat\apache-tomcat-8.0.15\logs\».

Если пункт 4 выполнен полностью успешно, то в окне браузера можно набрать 127.0.0.1:8080 и в окне будет окно tomcat сервера.

Но если мы захотим войти в настройки Host Manager, и т. д., то нас попросят ввыести логин и пароль. Взять их негде, но в папке conf есть файл tomcat-users.xml, который, если открыть, то сначала кажется правильным, но роли и пользователи там взяты в комментарий . Да и роли, и пользователи там явно неверные. Итак, что же делать.

Для ответа на вопрос, какие роли должны быть, и каких пользоватей назначать, чтобы войти в админку, на страничке 127.0.0.1:8080. Например, про роли manager можно узнать на страничке ttp://127.0.0.1:8080/docs/manager-howto.html, и вместо одного пользователя admin, как было раньше, теперь есть два пользователя: admin-gui и admin-script.

Более подробно про работу с паролями здесь http://127.0.0.1:8080/docs/realm-howto.html

Итак, открываем файл conf\tomcat-user.xml и добавляем там после закомментированного блока с логинами и паролями

Таким образом, мы получим пользователя superadmin с паролем pass.

Tеперь при помощи скриптов shutdown.bat и startup.bat перезапускаем сервер, и можем войти в админку.

можно ещё создать в админке ссылку на хост (Это то же самое, что мы сейчас сделали).

При создании новых записей в hosts для win8, сначала копируем файл в другую папку, там правим, и затем пишем обратно. После этого рестарт компьютера или сервера не нужен.

Оцените статью