1

I have a task to automaticly extend heap memory for our tomcat application. I know it isn't possible by JDK features, and I'm looking for any dirty(or not) hack to make that kinda feature. The main reason of that demand is minimal configuration of tomcat before start demo version of our application. In other word no user of our application will have any access to configuration of JVM/tomcat. Application required ~1024M of heap memory, default value for tomcat8 is 256M, which isn't appropriate for our goals.

At this moment I have two possible solutions:

  1. An a .sh/.bat script which will configure tomcat. pros - it will do the work, cons - it's another point of configuration demo stand(copying of a script)
  2. An wrapper for our application, which goes in the same war file and configure tomcat if required. pros - it will do the work, and no new configuration point(Just install tomcat and copy the war file),

Is there another way to do that in more... common and simple way?

EDIT The main goal is to make installation of our application in following steps:

  1. Install tomcat
  2. Copy war file
  3. Start tomcat

no any additional configuration, just copy war and start tomcat

Roman Makhlin
  • 973
  • 1
  • 11
  • 27
  • 2
    JVM does that automatically if you use the -Xms and -Xmx flags. Isn't that enough? See: https://stackoverflow.com/q/14763079/466738 – Adam Michalik Jul 31 '17 at 09:03
  • setenv.sh/bat is exactly what is assume the standard way to configure this. See https://stackoverflow.com/questions/43218169/what-exactly-setenv-sh-is-used-for-in-tomcat/44583906#44583906. The file is not there in a default install, you just create it and set `CATALINA_OPTS` with your intended memory configuration and you're good to go. No need to invent your own mechanism – Olaf Kock Jul 31 '17 at 10:32
  • Main goal is to exclude any action from from the side of whom installs our application, it's looks like it isn't common issue =( – Roman Makhlin Jul 31 '17 at 11:33

1 Answers1

1

That is commonly solved by wrapping the installation and configuration of tomcat in an installation script. Pros: the end user just download the installer and runs it; cons: the installation script must be tailored for the final environment (one for Windows, one for Linux) and can be hard to write. A sometimes simpler way is to provide a zip containing a readme.txt file and a install.bat (or install.sh)

An alternate way if the configuration is really complex is to directly configure a VM (VMDK is a de facto standard), and let the users install the virtualizer they prefere.

Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252