How to set JVM arguments in tomcat that work both in eclipse and using the startup.bat
Asked Answered
E

2

21

I have an installation of Tomcat 7 on windows to which I am deploying my app. I have a couple of JVM args that I need set for the applications running on the server. In searching around on the web I find two (three if you count the windows service) camps:

For those using eclipse:

Double click on the server > Open launch configuration > arguments tab

For those using tomcat's startup script:

Create a setenv.bat (or setenv.sh for Linux) and set either CATALINA_OPTS or JAVA_OPTS

However, they seem to be mutually exclusive. Setting the arguments in eclipse (+1 if you can tell where these are stored) don't affect the startup script and setting the setenv.bat properties don't affect the server when started within eclipse. Both work individually.

Both point to the same installation, and in eclipse on the overview page of the server, I have selected "Use Tomcat installation (takes control of Tomcat installation).

Externalism answered 13/12, 2012 at 23:15 Comment(1)
I just found this: #7388037. Here's a quote from the answer: It's important to understand that the Tomcat plugins provided by eclipse WTP (in my case Indigo) do not call the external (OS dependent) scripts to start/stop Tomcat. Instead they spawn the Tomcat JVM directly via the command line (java.exe ...).Externalism
E
19

As I mentioned in the comment above, it looks like the WTP plugins do not call the startup scripts, but directly call on Tomcat through the java executable. Therefore, the VM arguments from eclipse are put directly on the command line, not stored in some config file such as setenv.bat, neither does it read from such a config file from startup. Therefore the two are completely separate in configuration.

Externalism answered 17/12, 2012 at 16:23 Comment(0)
G
0

As far as I know, you can not do this in tomcat and should do extra work in eclipse's settings.
If your project is eclipse's dynamic web project, go to menu>runAs>runConfiguration and in environment tab, add those parameters that is in SetEnv.bat. If your project is multi module mavenized project, go to run configuration of that module that has war packaging in pom file and do the settings above mentioned. Also, in arguments tab, you can specify program arguments and VM arguments. Note: startup.bat runs another bat files that they may set another parameters. if you faced with any error, you may check other bat files.

Geny answered 18/7, 2021 at 23:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.