Java – Can’t install Tomcat 7 as a Service in Windows

apachejavatomcatwindowswindows-services

I'm trying to install tomcat as a service in Windows Server 2008.

I searched in stackoverflow and can't find any answer to this problem, i can see other related questions which all of them are not the same (are related to code error 0, mine is code error 1) or have not valid answers, so i decided to create this question.

I'm using this to create the service:

https://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html#Installing_services

tomcat7 //IS//Tomcat7 --DisplayName="Apache Tomcat 7" \

After the command, i can see in my Services list the Apache Tomcat 7 service, the problem is that it is stopped, if i try to start it, i can see this error:

Windows could not start the Apache Tomcat 7 on Local Computer. For
more information, review the System Event Log. If this is a
non-Microsoft service, contact the service vendor, and refer to
service-specific error code 1.

In the System Event Viewer i can see this log for this error:

The Apache Tomcat 7 service terminated with service-specific error Incorrect function..

I am using java 64 bits and i tested with both tomcat 32 and 64 bits, in both i have the same problem. I also tryed to open cmd.exe with administrator permission and i have the same problem…

Thanks for your help

FYI: if i start tomcat manually with startup.bat, it starts correctly

Best Answer

I solved it simply installing the service with other method:

service.bat install

this command will uninstall the service:

service.bat uninstall

Also to start it and to enable autostart, you must enter to the Services Manager of Windows (Servicios in spanish version) and start the service and enable autostart.

If you cand find service.bat file in tomcat/bin directory, read this:

apache-tomcat-[version].zip or .tar.gz
       Base distribution. These distributions do not include the Windows service wrapper nor the compiled APR/native library for Windows.

apache-tomcat-[version]-windows-x86.zip
       32-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 32-bit JVMs on both 32 and 64 bit Windows platforms.

apache-tomcat-[version]-windows-x64.zip
       64-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 64-bit JVMs on x64 Windows platforms.