LameCoder
LameCoder

Reputation: 1297

Neo4j 2.0.0RC1 StartService Failed 87

I've just downloaded RC2. I was running 1.9 without issues in the past. Running on Windows 7.

Here's what is happening when I install. All attempts to start the service fail with the 87 error message.

C:\Neo4j\Neo4JTest\neo4j-community-2.0.0-RC1\bin>Neo4jInstaller.bat install
"WARNING: this installer is deprecated and may not be the optimal way to install Neo4j on your system."
"Please see the Neo4j Manual for up to date information on installing Neo4j."
Press any key to continue
[SC] CreateService SUCCESS
[SC] StartService FAILED 87:

The parameter is incorrect.

Regarding the warning message: The installer doesn't seem to have an option for installing as a service, and I haven't seen any other instructions in the manual for installing as a service.

http://docs.neo4j.org/chunked/2.0.0-RC1/server-installation.html#windows-install

Upvotes: 2

Views: 2436

Answers (4)

pronebird
pronebird

Reputation: 12230

The same error (87) pops up if environment configuration in windows registry at HKLM\SYSTEM\CurrentControlSet\Services\<SERVICE NAME>\Environment is set to empty string. Removing it solves the problem.

Upvotes: 0

ttt
ttt

Reputation: 6809

As this is the first results which pops up in google when searching for: "[SC] StartService FAILED 87: The parameter is incorrect."

Check the path again. In most cases the error is in the quoted path.

I run into this problem when creating a windows service with .NET Core 2.0.

Path example:

sc create YourServiceName binPath= "C:\Users\john\source\published\YourServiceName\YourServiceName.exe"

My mistake was a space:

sc create YourServiceName binPath= " C:\Users\john\source\published\YourServiceName\YourServiceName.exe"

Upvotes: 0

EdH
EdH

Reputation: 36

Neo4j 2.0.0-RC1
neo4j-community-2.0.0-RC1-windows
Windows 7

neo4j>bin\Neo4jInstaller.bat install

[SC] CreateService SUCCESS
[SC] StartService FAILED 87:
The parameter is incorrect.

This problem is the result of a combination of bugs in the new Neo4j installation bat files that result in a corrupt binPath= parameter in the sc create service command in the Neo4jInstaller.bat file itself.

Specifically, the sc create command requires the binPath= parameter in this instance to be quoted, as there are embedded spaces within the Neo4j %binPath% variable. However, the sc create command created within Neo4jInstaller.bat contains unescaped quotes and an erroneous space embedded in the %javaPath% variable within the %binPath% variable definition.

To fix this, two files need to be edited:

bin\functions.bat
bin\Neo4jInstaller.bat

The invalid space embedded in the %javaPath% variable is caused by a space after the "=" sign in the set javaPath="%JAVA_HOME%" command in functions.bat.

The unescaped quotes in %binPath% require three changes in Neo4jInstaller.bat:

  1. The quotes in the %javaPath% variable must be removed before is is embedded in the %binPath% variable.
  2. The entire %javaPath%\bin\java.exe path must be enclosed in quotes.
  3. The %binPath% variable value must be enclosed in quotes, and the quotes embedded within the %binPath% variable must be escaped.

Additionally, the call to functions.bat within Neo4jInstaller.bat must be modified, because functions.bat resides in the \bin subdirectory, and Neo4jInstaller.bat must be run from the root neo4j directory.

functions.bat
=============
:findJavaHome
  if not "%JAVA_HOME%" == "" (

    if exist "%JAVA_HOME%\bin\javac.exe" (
rem      set javaPath= "%JAVA_HOME%\jre"
      set javaPath="%JAVA_HOME%\jre"
      goto:eof
    )

rem    set javaPath= "%JAVA_HOME%"
    set javaPath="%JAVA_HOME%"
    goto:eof
  )


Neo4jInstaller.bat
==================

rem  call functions.bat :findJavaHome
rem set javaPath=%javaPath:"="""%

rem  set binPath="%javaPath%\bin\java.exe %loggingProperties% -DworkingDir="%~dps0.." -DconfigFile=%configFile% %classpath% %mainclass% -Dorg.neo4j.cluster.logdirectory="%~dps0..\data\log" -jar %~dps0%wrapperJarFilename%  %serviceName%"

  call %~dps0functions.bat :findJavaHome
  set javaPath=%javaPath:"=%

  set binPath="%javaPath%\bin\java.exe" %loggingProperties% -DworkingDir="%~dps0.." -DconfigFile=%configFile% %classpath% %mainclass% -Dorg.neo4j.cluster.logdirectory="%~dps0..\data\log" -jar %~dps0%wrapperJarFilename%  %serviceName%

  set binPath="%binPath:"=\"%"


There is a "Closed" Neo4j ticket on GitHub at https://github.com/neo4j/neo4j/pull/1535 that only partially fixes these issues for RC2. However, in the meantime, you will have to fix this yourself.

Upvotes: 2

LameCoder
LameCoder

Reputation: 1297

So here's what I discovered.

There's a registry key here: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services_whatever_you_named_the_service

The Image Path has quotes like so:

"C:\Program Files\Java\jdk1.7.0_21\jre"\bin\java.exe ....

I removed the quotes

C:\Program Files\Java\jdk1.7.0_21\jre\bin\java.exe ....

It now works.

Looking at the bat file it's finding javaPath from my JAVA_HOME env variable and setting %javaPath% with quotes around it in functions.bat.

Then there's a part that's adding three extra quotes in place of any existing quotes in the javaPath on line 55 of Neo4jInstaller.bat

set javaPath=%javaPath:"="""%

Found this on the GitHub, not sure if it is going to fix this issue considering someone elses comment regarding the issue: https://github.com/neo4j/neo4j/pull/1535

Upvotes: 0

Related Questions