Bug 61590

Summary: service.bat fails to recognize JDK 9
Product: Tomcat 9 Reporter: Konstantin Preißer <kpreisser>
Component: PackagingAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 9.0.1   
Target Milestone: -----   
Hardware: PC   
OS: All   
Attachments: Patch to correctly detect JDK 9

Description Konstantin Preißer 2017-10-07 13:09:58 UTC
Created attachment 35399 [details]
Patch to correctly detect JDK 9

When trying to install Tomcat 9.0.1 on Windows (x64) where the JAVA_HOME environment variable points to the JDK 9, service.bat fails to recognize the Java binaries:

> C:\apache-tomcat-9.0.1\bin>service install
> The JAVA_HOME environment variable is not defined correctly
> This environment variable is needed to run this program
> NB: JAVA_HOME should point to a JDK not a JRE

This is because service.bat checks for "java.exe", "javaw.exe" and "server\jvm.dll" within a "jre\bin" directory, but the "jre" directory doesn't exist on JDK 9.

Instead, the necessary binaries can be found directly within the JDK's "bin" folder.

Note: Running the Tomcat Service using the SYSTEM user (root) works, but if you want to run the Tomcat Service as a different user with Java 9, it seems that additionally to having access to the Tomcat directory (e.g. "D:\Tomcat"), the user also must have read access access to its parent directory (e.g. "D:\") (or even the drive root) for some reason.
Otherwise (if the user only has access to the Tomcat directory), starting the service will fail and the following error will be printed to stderr.log:

> 2017-10-07 14:52:24 Commons Daemon procrun stderr initialized
> java.lang.NoClassDefFoundError: org/apache/catalina/startup/Bootstrap
> Caused by: java.lang.ClassNotFoundException: > org.apache.catalina.startup.Bootstrap
>    at > java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
>    at > java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
>    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
Exception in thread "main" 

This isn't the case with Java 8, where it is sufficient to have access to only the Tomcat directory.
Comment 1 Mark Thomas 2017-10-09 12:32:37 UTC
Fixed in:
- trunk for 9.0.2 onwards
- 8.5.x for 8.5.24 onwards
- 8.0.x for 8.0.48 onwards
- 7.0.x for 7.0.83 onwards