You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Artur Linhart (Jira)" <ji...@apache.org> on 2019/10/16 09:28:00 UTC

[jira] [Updated] (TOMEE-2712) TomEE Windows service cannot be correctly installed if only JRE present (errors in service.bat, maybe it fails even with JDK used)

     [ https://issues.apache.org/jira/browse/TOMEE-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Artur Linhart updated TOMEE-2712:
---------------------------------
    Description: 
In the batch service.bat can be defined explicitly the user JDK/JRE. But if you specify JRE, then the batch crashes installing the service. It happens at least for Java 11.

 

Steps to reproduce:

1. Put below the comments:

rem The following line can be used to define a specific jre or jdk path
 rem set "JAVA_HOME=C:/JDK"

the line specifying JRE, something like:
 set "JRE_HOME=D:/Tomee/server-jre"

2. call the service installation by calling something like
 service.bat install my_service_name

3. The service.bat batch starts with the installation, but the installation happens only partially, ends with the messages
 " ...
 Using Service User: ""
 Installed, will now configure TomEE
 11 was unexpected at this time."

4. There is still the service installed, but incompletely - there is no "Options" key in the registry folder
 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\my_service_name\Parameters\Java

created and the service cannot be started through "Services" snap-in of MMC.

5. The starting of TomEE service fails with "Error 5: Access is denied." error in the case of the used default "Local Service" account. If you switch to the built-in "Local System" account, then the start crashes with the error "Error 1067: The process terminated unexpectedly."

The error in the service.bat behind in the labels ":okHome" and ":gotJreHome" where is missing the resolution of the variable JAVA_MAJOR_VERSION, like it is done behind the label :gotJdkHome where is the setting of the variable done by statement
 for /f tokens^=2^ delims^=.-_^" %%j in ('"%JAVA_HOME%\bin\java.exe" -fullversion 2^>^&1') do set "JAVA_MAJOR_VERSION=%%j"

So, workaround for now is, to put following statements also behind the labels mentioned above (okHome and gotJreHome) immediatelly before the jump 
 goto okJavaHome on line 91 or similary it suits to the current configuration:

for /f tokens^=2^ delims^=.-_^" %%j in ('"%JRE_HOME%\bin\java.exe" -fullversion 2^>^&1') do set "JAVA_MAJOR_VERSION=%%j"
 - but in the case of the guessed JRE this will very probably fail too.

There is also the another error on the lines 94-97 which might prevent the installation of the service even in the case of the JDK usage, it is:

if JAVA_MAJOR_VERSION lss 11 (
 if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
 if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
 )

should be written like

if {color:#ff0000}*%*{color}JAVA_MAJOR_VERSION*{color:#ff0000}%{color}* lss 11 (
 if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
 if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
 )

  was:
If the batch service.bat can be defined explicitly the user JDK/JRE. But if you specify JRE, then the batch crashes installing the service. It happens at least for Java 11.

 

Steps to reproduce:

1. Put below the comments:

rem The following line can be used to define a specific jre or jdk path
rem set "JAVA_HOME=C:/JDK"

the line specifying JRE, something like:
set "JRE_HOME=D:/Tomee/server-jre"

2. call the service installation by calling something like
service.bat install my_service_name

3. The service.bat batch starts with the installation, but the installation happens only partially, ends with the messages
" ...
Using Service User: ""
Installed, will now configure TomEE
11 was unexpected at this time."

4. There is still the service installed, but incompletely - there is no "Options" key in the registry folder
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\my_service_name\Parameters\Java

created and the service cannot be started through "Services" snap-in of MMC.

5. The starting of TomEE service fails with "Error 5: Access is denied." error in the case of the used default "Local Service" account. If you switch to the built-in "Local System" account, then the start crashes with the error "Error 1067: The process terminated unexpectedly."

The error in the service.bat behind in the labels ":okHome" and ":gotJreHome" where is missing the resolution of the variable JAVA_MAJOR_VERSION, like it is done behind the label :gotJdkHome where is the setting of the variable done by statement
for /f tokens^=2^ delims^=.-_^" %%j in ('"%JAVA_HOME%\bin\java.exe" -fullversion 2^>^&1') do set "JAVA_MAJOR_VERSION=%%j"

So, workaround for now is, to put following statements also behind the labels mentioned above (okHome and gotJreHome) immediatelly before the jump 
goto okJavaHome on line 91 or similary it suits to the current configuration:

for /f tokens^=2^ delims^=.-_^" %%j in ('"%JRE_HOME%\bin\java.exe" -fullversion 2^>^&1') do set "JAVA_MAJOR_VERSION=%%j"
- but in the case of the guessed JRE this will very probably fail too.

There is also the another error on the lines 94-97 which might prevent the installation of the service even in the case of the JDK usage, it is:

if JAVA_MAJOR_VERSION lss 11 (
 if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
 if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
)

should be written like

if {color:#FF0000}*%*{color}JAVA_MAJOR_VERSION*{color:#FF0000}%{color}* lss 11 (
 if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
 if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
)


> TomEE Windows service cannot be correctly installed if only JRE present (errors in service.bat, maybe it fails even with JDK used)
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TOMEE-2712
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2712
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 8.0.0-Final
>         Environment: JAva 11.0.4-10, Tomee 8.0.0-final package "Plus", Windows Server 2012 R2 Datacenter, 64 bit
>            Reporter: Artur Linhart
>            Priority: Major
>
> In the batch service.bat can be defined explicitly the user JDK/JRE. But if you specify JRE, then the batch crashes installing the service. It happens at least for Java 11.
>  
> Steps to reproduce:
> 1. Put below the comments:
> rem The following line can be used to define a specific jre or jdk path
>  rem set "JAVA_HOME=C:/JDK"
> the line specifying JRE, something like:
>  set "JRE_HOME=D:/Tomee/server-jre"
> 2. call the service installation by calling something like
>  service.bat install my_service_name
> 3. The service.bat batch starts with the installation, but the installation happens only partially, ends with the messages
>  " ...
>  Using Service User: ""
>  Installed, will now configure TomEE
>  11 was unexpected at this time."
> 4. There is still the service installed, but incompletely - there is no "Options" key in the registry folder
>  HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\my_service_name\Parameters\Java
> created and the service cannot be started through "Services" snap-in of MMC.
> 5. The starting of TomEE service fails with "Error 5: Access is denied." error in the case of the used default "Local Service" account. If you switch to the built-in "Local System" account, then the start crashes with the error "Error 1067: The process terminated unexpectedly."
> The error in the service.bat behind in the labels ":okHome" and ":gotJreHome" where is missing the resolution of the variable JAVA_MAJOR_VERSION, like it is done behind the label :gotJdkHome where is the setting of the variable done by statement
>  for /f tokens^=2^ delims^=.-_^" %%j in ('"%JAVA_HOME%\bin\java.exe" -fullversion 2^>^&1') do set "JAVA_MAJOR_VERSION=%%j"
> So, workaround for now is, to put following statements also behind the labels mentioned above (okHome and gotJreHome) immediatelly before the jump 
>  goto okJavaHome on line 91 or similary it suits to the current configuration:
> for /f tokens^=2^ delims^=.-_^" %%j in ('"%JRE_HOME%\bin\java.exe" -fullversion 2^>^&1') do set "JAVA_MAJOR_VERSION=%%j"
>  - but in the case of the guessed JRE this will very probably fail too.
> There is also the another error on the lines 94-97 which might prevent the installation of the service even in the case of the JDK usage, it is:
> if JAVA_MAJOR_VERSION lss 11 (
>  if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
>  if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
>  )
> should be written like
> if {color:#ff0000}*%*{color}JAVA_MAJOR_VERSION*{color:#ff0000}%{color}* lss 11 (
>  if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
>  if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
>  )



--
This message was sent by Atlassian Jira
(v8.3.4#803005)