Stash service (64-bit) fails to start - not a valid Win32 application
症状
After upgrading to Stash, the Stash service will no longer start. Trying to run "NET START STASH" gives the following:
The Atlassian Stash service could not be started.
A service specific error occured: 1.
The System event log has the following message:
The Atlassian Stash service terminated with service-specific error Incorrect function.
The following appears in the log: <Stash install directory>/logs/commons-daemon.YYYY-MM-DD.log
[2013-02-19 20:51:42] [info] Commons Daemon procrun (1.0.10.0 64-bit) started
[2013-02-19 20:51:42] [info] Running 'stash' Service...
[2013-02-19 20:51:42] [info] Starting service...
[2013-02-19 20:51:42] [error] %1 is not a valid Win32 application.
[2013-02-19 20:51:42] [error] Failed creating java C:\devTools\Java\x32\jdk1.6.0_33\jre\bin\server\jvm.dll
[2013-02-19 20:51:42] [error] %1 is not a valid Win32 application.
[2013-02-19 20:51:42] [error] ServiceStart returned 1
[2013-02-19 20:51:42] [error] %1 is not a valid Win32 application.
[2013-02-19 20:51:42] [info] Run service finished.
[2013-02-19 20:51:42] [info] Commons Daemon procrun finished
However, Stash will be up and running if you run it directly, as in executing the start-stash.bat file. Tomcat comes up running and everything will work.
原因
- You have a 64-bit OS and you skipped the custom changes that have to be done to your new installation.
- There is a mismatch between the Java JVM (32-bit) and the Stash binary (64-bit).
- Your Stash service is pointing to the incorrect JVM which causes the mismatch described above
ソリューション
1. Skipped custom changes
If you are using a 64-bit version of Windows, first ensure that Stash uses a 64-bit JVM (check by running java -version
in a Command Prompt, and ensure that the JAVA_HOME
system environment variable points to the 64-bit JVM), and then replace the 32-bit Tomcat binaries with their 64-bit counterparts in the <Stash installation directory>/bin
directory:
cd <STASH-INST/bin>
rename tomcat7.exe tomcat7.exe.x86
rename tcnative-1.dll tcnative-1.dll.x86
rename tomcat7.exe.x64 tomcat7.exe
rename tcnative-1.dll.x64 tcnative-1.dll
2. JVM mismatch
- Remove the existing service, e.g.
<Stash install directory>/bin/service remove
- Install a 64-bit Java JDK.
- Open a shell window and ensure
JAVA_HOME
points to the root install folder of the Java version, e.g.C:\devTools\Java\x64\jdk1.7.0_10
- Install the service, e.g.
<Stash install directory>/bin/service install
The value of JAVA_HOME
is set upon service creation (either via the system or local variable). Changing the value of the system variable after the service has been installed will have no affect on the service.
3. Your Windows service is pointing to the incorrect JVM
Sometimes you could be
サービス名
If you don't know the exact name of your old Stash service, you can find out what they are by following the steps below:
- Navigate to 'Control Panel' > 'Administrative Tools' > 'Services'.
- The 'Services' window should appear.
- Right-click on the service you wish to find out the name of, and select 'Properties' from the popup menu.
- The 'Service name' should appear in the 'General' tab.
- Use this parameter as a substitute for
<ServiceName here>
on the command below.
- Use this parameter as a substitute for
Start >> Run >> type in 'cmd' >> Enter
でコマンド ウィンドウを開きます。cd
to thebin
directory the Stash Installation (<Stash Installation dir>/bin
).Run from there:
tomcat8w //ES//<ServiceName here>
A window will pop up. Click on the Java tab. On the field "Java Virtual Machine" check the value that is input.
It will be
%JAVA_HOME%\bin\server\jvm.dll
. For example, there was a situation that the customer had:- C:\program files\java\jre1.8.0_45\bin\server\jvm.dll
- But we pointed his service to a different JRE: C:\Program Files\Java\jre1.8.0_60\bin\server\jvm.dll