2011-10-12 17 views
32

¿Cómo puedo agregar opciones de jvm (máquina virtual Java) en Apache Tomcat 6?agregar opciones de jvm en tomcat

¿Hay una consola de administración en tomcat? Intenté http://localhost:8080/admin pero no pude sacar nada.

Quiero añadir las siguientes opciones de JVM:

-agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5 

Respuesta

21

Set en la variable JAVA_OPTS en [ruta de Tomcat] /bin/catalina.sh. En Windows hay una consola donde puedes configurarla o usar catalina.bat.

JAVA_OPTS=-agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5 
+9

Al menos en Tomcat 7, esto no es el lugar recomendado para personalizaciones. De 'catalina.sh':" No establezca las variables en este script. En su lugar, colóquelas en un script setenv.sh en CATALINA_BASE/bin para mantener sus personalizaciones separadas ". Además, como señala Mitch, 'CATALINA_OPTS' es la variable más canónica para almacenar esto. –

+2

Para expandir en setenv.sh, aquí hay una entrada de ejemplo:' export CATALINA_OPTS = "$ CATALINA_OPTS -XX: MaxPermSize = 256m" '(this aumentaría el tamaño máximo de la permanente). – idaWHALE

17

Para esto necesita ejecutar la aplicación "tomcat6w" que es parte de la distribución estándar de Tomcat en el directorio "bin". P.ej. para Windows, el valor predeterminado es "C: \ Archivos de programa \ Apache Software Foundation \ Tomcat 6.0 \ bin \ tomcat6w.exe". La aplicación "tomcat6w" inicia una GUI. Si selecciona la pestaña "Java" puede ingresar todas las opciones de Java.

También es posible pasar las opciones de JVM a través de la línea de comando a tomcat. Para ello, tiene que utilizar el comando:

<tomcatexecutable> //US//<tomcatservicename> ++JvmOptions="<JVMoptions>" 

donde "tomcatexecutable" se refiere a su aplicación Tomcat, "tomcatservicename" es el nombre del servicio Tomcat que está utilizando y "JVMoptions" son sus opciones de JVM. Por ejemplo:

"tomcat6.exe" //US//tomcat6 ++JvmOptions="-XX:MaxPermSize=128m" 
+0

Esto significa que Tomcat siempre tendrá que iniciarse como un servicio para que los cambios surtan efecto, por lo tanto, el primer enfoque debería ser mejor – frewper

28

Como dice Bhavik Shah, puede hacerlo en JAVA_OPTS, pero la forma recomendada (según catalina.sh) es utilizar CATALINA_OPTS:

# CATALINA_OPTS (Optional) Java runtime options used when the "start", 
#     "run" or "debug" command is executed. 
#     Include here and not in JAVA_OPTS all options, that should 
#     only be used by Tomcat itself, not by the stop process, 
#     the version command etc. 
#     Examples are heap size, GC logging, JMX ports etc. 

# JAVA_OPTS  (Optional) Java runtime options used when any command 
#     is executed. 
#     Include here and not in CATALINA_OPTS all options, that 
#     should be used by Tomcat and also by the stop process, 
#     the version command etc. 
#     Most options should go into CATALINA_OPTS. 
9

Después de comprobar catalina.sh (para utilizar windows las versiones .bat de todo lo mencionado más adelante)

# Do not set the variables in this script. Instead put them into a script 
# setenv.sh in CATALINA_BASE/bin to keep your customizations separate. 

también este

# CATALINA_OPTS (Optional) Java runtime options used when the "start", 
#     "run" or "debug" command is executed. 
#     Include here and not in JAVA_OPTS all options, that should 
#     only be used by Tomcat itself, not by the stop process, 
#     the version command etc. 
#     Examples are heap size, GC logging, JMX ports etc 

Por lo tanto, cree un setenv.sh en CATALINA_BASE/bin (mismo directorio donde reside catalina.sh). Edite el archivo y establezca los argumentos en CATALINA_OPTS

Por ej. el archivo se vería como esto si usted quiere cambiar el tamaño del montón

CATALINA_OPTS=-Xmx512m 

o en su caso, ya que se está utilizando Windows setenv.bat sería

set CATALINA_OPTS=-agentpath:C:\calltracer\jvmti\calltracer5.dll=traceFile-C:\calltracer\call.trace,filterFile-C:\calltracer\filters.txt,outputType-xml,usage-uncontrolled -Djava.library.path=C:\calltracer\jvmti -Dcalltracerlib=calltracer5 

Para borrar las opciones añadidas más tarde sólo eliminar setenv.bat/sh

1

si desea establecer argumentos de JVM en Eclipse que puede utilizar a continuación:

ver a continuación dos enlaces para lograrlo:

  1. eclipse setting to pass jvm args to java
  2. eclipse setting to pass jvm args to java and adding to run config on eclipse

Y para tomcat puede Crear un archivo setenv.bat en la carpeta bin de tomcat y agregarle líneas a continuación:

• echo "hola im setenv de partida"

• conjunto CATALINA_OPTS = -DNLP.home = $ {} NLP.home -Dhostname = $ {}

nombre de host
Cuestiones relacionadas