You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2020/08/04 12:42:56 UTC
[Bug 64645] New: bin/service.bat doesn't handle wrongly configured
JAVA_HOME
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
Bug ID: 64645
Summary: bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Product: Tomcat 9
Version: 9.0.x
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: dev@tomcat.apache.org
Reporter: jakub.moravec@getmanta.com
Target Milestone: -----
This seems to be similar to
https://bz.apache.org/bugzilla/show_bug.cgi?id=49993, maybe the validation just
needs to be enhanced.
Hello,
this is my first ticket in Apache Bugzilla, please bear with me.
We found out, that if JAVA_HOME is wrongly configured (for example if it
points to JRE instead of JDK), the service.bat script won't fail, will skip to
and return exit code 0.
This is misleading, as the service was not installed because of wrongly
set-up JAVA_HOME.
Is it possible to provide better validation and make sure, that the exit code
is not 0 in case the installation of the service fails?
I believe that swallowing of exceptions is not a good approach ;)
Thanks!
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
--- Comment #7 from Christopher Schultz <ch...@christopherschultz.net> ---
This seems like a different bug to me. JRE or JDK should be fine either way.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
--- Comment #9 from Jakub Moravec <ja...@getmanta.com> ---
Thank you, Mark and Christopher!
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|REOPENED |RESOLVED
--- Comment #8 from Mark Thomas <ma...@apache.org> ---
One of JRE_HOME, JAVA_HOME or neither is acceptable. JAVA_HOME takes priority
over JRE_HOME. If neither is set, the registry is used.
If JAVA_HOME is configured to point to a JRE then:
- the service install is not attempted
- an error message is displayed
and, now that this bug is fixed
- the script completes with a non-zero return code
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
--- Comment #2 from Jakub Moravec <ja...@getmanta.com> ---
Thanks for the response Christopher. I dug a bit deeper...
(In reply to Christopher Schultz from comment #1)
> (In reply to Jakub Moravec from comment #0)
> > We found out, that if JAVA_HOME is wrongly configured (for example if it
> > points to JRE instead of JDK), the service.bat script won't fail, will skip
> > to and return exit code 0.
>
> JAVA_HOME should be able to point to either a JRE or JDK. Tomcat hasn't
> required a JDK for a very long time.
I noticed, that there is some logic in service.bat (for Java versions in which
JDK and JRE were still distributed separately), that for example appends the
'/jre' absolute path segment to the JAVA_HOME. Also, the structure of the
target folder seems to be somehow validated. I'm not what is the exact reason,
but I expect that due to one of those facts the script prints the following
messages and skips to an end.
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 misleading, as the service was not installed because of wrongly
> > set-up JAVA_HOME.
>
> If true, I agree.
Yes, as I mentioned, the log messages are printed, but that is the only
indication that services were not installed. Script return code is 0 which
makes it hard to handle this issue in automated solution.
> > Is it possible to provide better validation and make sure, that the exit
> > code is not 0 in case the installation of the service fails?
>
> Probably the best way to check for JAVA_HOME validity is to actually launch
> the JVM with some trivial task (even just "java.exe --help") to make sure it
> executes successfully, would you agree?
It sounds reasonable, but since I am not sure what is the exact cause of this
issue, I cannot say that this will suffice.
> > I believe that swallowing of exceptions is not a good approach ;)
>
> Do you believe there is an error being swallowed? Which one?
I'm referring to the fact that the response code is 0 - the script is acting
like nothing bad happened even though the service was not installed.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
--- Comment #3 from Mark Thomas <ma...@apache.org> ---
For clarity, the only change required here is that the exit code should be
non-zero. The validation of JAVA_HOME and JAVA_HOME vs JRE_HOME is sufficient.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
Christopher Schultz <ch...@christopherschultz.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--- Comment #1 from Christopher Schultz <ch...@christopherschultz.net> ---
(In reply to Jakub Moravec from comment #0)
> https://bz.apache.org/bugzilla/show_bug.cgi?id=49993, maybe the validation
> just needs to be enhanced.
+1
> We found out, that if JAVA_HOME is wrongly configured (for example if it
> points to JRE instead of JDK), the service.bat script won't fail, will skip
> to and return exit code 0.
JAVA_HOME should be able to point to either a JRE or JDK. Tomcat hasn't
required a JDK for a very long time.
> This is misleading, as the service was not installed because of wrongly
> set-up JAVA_HOME.
If true, I agree.
> Is it possible to provide better validation and make sure, that the exit
> code is not 0 in case the installation of the service fails?
Probably the best way to check for JAVA_HOME validity is to actually launch the
JVM with some trivial task (even just "java.exe --help") to make sure it
executes successfully, would you agree?
> I believe that swallowing of exceptions is not a good approach ;)
Do you believe there is an error being swallowed? Which one?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
--- Comment #4 from Jakub Moravec <ja...@getmanta.com> ---
Hi Mark,
changing the exit code is definitely the most important action here.
That being said, my understanding is that at the moment, the validation
doesn't recognize that JRE is referenced by JAVA_HOME and thus the process
fails during installation of the service. If the validation was able to
recognize this and fail it sooner (with proper exit code), that seems to me to
be a better solution.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
Jakub Moravec <ja...@getmanta.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |---
Status|RESOLVED |REOPENED
--- Comment #6 from Jakub Moravec <ja...@getmanta.com> ---
Hi Mark,
as far as I know, the current validation only checks that JAVA_HOME is
setup, but the validation will pass even if the target of JAVA_HOME is a JRE
(not a JDK), which will then cause the error I'm describing.
This issue is easy to reproduce:
* point JAVA_HOME to JRE (e.g. 1.8)
* try to use service.bat to install the Tomcat service
* the script will complete with no indication of failure, but the service is
not installed
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 64645] bin/service.bat doesn't handle wrongly configured
JAVA_HOME
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64645
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Mark Thomas <ma...@apache.org> ---
Your understanding is incorrect. The scripts checks the validity of JAVA_HOME
and exits before it attempts to install the service if it is invalid.
Fixed in:
- master for 10.0.0-M8 onwards
- 9.0.x for 9.0.38 onwards
- 8.5.x for 8.5.58 onwards
- 7.0.x for 7.0.106 onwards
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org