0

I am trying to run Tomcat10 on my PC having Window's 11 Pro. Upon running startup.bat, a window just opens and closes without showing a running server. All JRE_HOME, JAVA_HOME, CATALINA_HOME, CATALINA_BASE are set correctly.

Upon running "catalina configtest" I have found the following errors:

Using CATALINA_OPTS: "" Unrecognized option: --add-opens=java.base/java.lang=ALL-UNNAMED Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

output on the command prompt after running "catalina configtest"

Now couldn't figure out how to fix this configuration issue to get the server running.

I want to understand the reason for the errors, so I can fix them.

nqmeh
  • 21
  • 4
  • i think the problem is in the CATALINA_OPTS; which I tried to set using the command prompt while looking on [this thread about JVM options](https://stackoverflow.com/questions/58768474/jvm-options-while-running-tomcat8-using-startup-bat-on-windows). – nqmeh Apr 30 '23 at 12:40
  • Use Java 11 or newer. The official listing of Tomcat versions and related compatible Java versions can be found [here](https://tomcat.apache.org/whichversion.html). – andrewJames Apr 30 '23 at 15:14
  • "_I want to understand the reason_" - Your specific error relates to Java modules - which were [introduced in Java 9](https://www.oracle.com/ca-en/corporate/features/understanding-java-9-modules.html). See also [Migrating From JDK 8 to Later JDK Releases](https://docs.oracle.com/en/java/javase/11/migrate/index.html#JSMIG-GUID-7744EF96-5899-4FB2-B34E-86D49B2E89B6), where `--add-opens` is discussed. So, basically, your config was trying to use a flag which does not exist in Java 8. – andrewJames Apr 30 '23 at 15:17
  • unfortunately, it doesn't work, as the JAVA_OPTS was set as: -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -D-add-opens=java.base/java.lang=ALL-UNNAMED -D-add-opens=java.base/java.io=ALL-UNNAMED -D-add-opens=java.base/java.util=ALL-UNNAMED -D-add-opens=java.base/java.util.concurrent=ALL-UNNAMED -D-add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED – nqmeh Apr 30 '23 at 18:14
  • Searching for a recent JRE is a red herring. I think this counts as a new question (but probably one which may already have an answer somewhere on SO). My best suggestion: Describe how you installed Java 11 (and why not just go with a more up-to-date version, anyway?); describe how you installed Tomcat 10.1; describe how you launch Tomcat - and what value (if any) is set for `%JAVA_HOME%`. Finally, describe any errors you get when launching Tomcat. (If it helps: for me, I have my `%JAVA_HOME%` set to `C:\Program Files\Eclipse Adoptium\jdk-17.0.4.8-hotspot`.) https://adoptium.net/ – andrewJames Apr 30 '23 at 19:40
  • Regarding "_a window just opens and closes..._" - Depends exactly how you try to launch Tomcat, but my suggestion (in case you are not already doing this): (1) Open a command prompt. (2) `cd` to the Tomcat installation directory and then into its `bin` directory. (3) Type the command `startup.bat`. You should stand a better chance of seeing the immediate startup error that way. If you just double-click on the `startup.bat` file in a file explorer, you may have the problem you described (window flashes open and then closes too fast to see any errors). – andrewJames Apr 30 '23 at 19:48
  • tried both but in vain – nqmeh Apr 30 '23 at 19:57
  • Tried what _exactly_? – andrewJames Apr 30 '23 at 20:00
  • I mean, no success after typing on the command prompt inside tomcat dir; nor double clicking in the batch file. https://adoptium.net/ is providing but inside downloaded OpenJDK there is no jre11. – nqmeh Apr 30 '23 at 20:12
  • My best suggestion (again): Describe how you installed Java 11 (or Java 17 if you installed that); describe how you installed Tomcat 10.1; describe how you launch Tomcat - and what value (if any) is set for `%JAVA_HOME%`. And again, searching for a JRE is a red herring (apologies if that phrase is not clear - I mean it's irrelevant and just a distraction). Bottom line: **Help us to take the guesswork out of your situation.** Be specific and precise. – andrewJames Apr 30 '23 at 20:19
  • frankly, I just need for learning purpose only; will try some other day to use [jlink to get jre11](https://stackoverflow.com/questions/51403071/create-jre-from-openjdk-windows). So currently I have downgraded tomcat version. Thank you for the suggestions. – nqmeh Apr 30 '23 at 21:04

1 Answers1

0

Tomcat10.1 needs Java 11. It does not work with Java 1.8 which I see you are using from the screen cap. See here

John Williams
  • 4,252
  • 2
  • 9
  • 18
  • thankyou @john-Williams, but even the server didn't run even after installing JDK17 and updating the JAVA_HOME. I noticed that JVM will take the javapath var at C:\Program Files\Common Files\Oracle\Java\javapath set automatically by Oracle. I removed it in order to use the new JDK17 but in vain. After noticing that [JRE11 is no more supported by oracle](https://stackoverflow.com/questions/53733312/where-is-jre-11); now I am trying [how to get JRE11](https://stackoverflow.com/questions/53111921/how-can-i-get-java-11-run-time-environment-working-since-there-is-no-more-jre-11). – nqmeh Apr 30 '23 at 18:10