start tomcat with specific java parameters

29,558

The "official" way to set extra parameters to Tomcat is via creating bin/catalina.sh in Unix or bin\catalina.bat in Windows. In your (Windows) case, the file should look like as follows:

set CATALINA_OPTS=%CATALINA_OPTS% -Djavax.net.debug=all
Share:
29,558
Cratylus
Author by

Cratylus

Updated on March 12, 2020

Comments

  • Cratylus
    Cratylus about 4 years

    I am starting Tomcat using the startup.bat in the TOMCAT_HOME\bin directory.
    I need to enable all the java's debugging traces.
    In my web app (Note: Actually it is an axis2 web service) I did:
    System.setProperty("javax.net.debug","all");
    But it did not work.
    Nothing printed to Tomcat console.
    I tried to put this property as parameter in Tomcat on start-up so I edited the catalina.bat as follows:
    Before:

    if not "%LOGGING_MANAGER%" == "" goto noJuliManager
    set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    :noJuliManager
    set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%
    

    After:

    if not "%LOGGING_MANAGER%" == "" goto noJuliManager
    set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    :noJuliManager
    set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%
    set JAVA_OPTS=-Djavax.net.debug=all %JAVA_OPTS%
    

    I am not sure if this is the write place to put it in catalina.bat, but it seemed reasonable to me.
    No success as well.
    So how can I start tomcat with a -Djava option?
    Specifically how can I enable

    System.setProperty("javax.net.debug","all"); so that I can do the debugging in my web app?

    Thank you.

  • Cratylus
    Cratylus about 13 years
    Tried it but no success.But may be I am wrong here.I see in the java code the following: if (debug != null) {debug.println("---checking " + msg + "..."); etc is this not supposed to go to console? Also no extra debugging traces are shown in the Tomcat console even with this option
  • mindas
    mindas about 13 years
    Try launch Tomcat by calling "catalina.bat run" so the output goes to your stdout (and watch it), maybe your logging configuration is misconfigured?