Apache tomcat7作为Windows服务

Apache tomcat7作为Windows服务

问题描述:

我正在尝试为Apache tomcat 7.0.45创建Windows服务.(在Windows版本7中)

I am trying to create a windows service for Apache tomcat 7.0.45. ( in windows version 7)

我执行了这个:

C:/tomcat7/bin> service install Mytomcat7

Windows服务已创建.但它不会启动并抛出特定服务器错误代码4".

Windows service has been created. but it wont start and throws "specific server error code 4".

请帮助您创建Windows服务的步骤.

Can you please help with the steps to create windows service.

我遇到了同样的问题!

发现,service.bat没有正确配置服务.如果您从服务启动器启用日志记录:

Found out, that the service.bat didn't configure the service the right way. If you enable the logging from your service starter:

然后,您会在日志中看到类似以下内容的

Then you'll see in your loggs something like:

[2014-02-19 16:40:35] [error] ( javajni.c:863 ) [ 2636] FindClass org/apache/catalina/startup/Bootstrap failed
[2014-02-19 16:40:35] [debug] ( javajni.c:964 ) [ 2636] Java Worker thread finished org/apache/catalina/startup/Bootstrap:main with status=3
[2014-02-19 16:40:35] [error] ( prunsrv.c:1183) [ 5000] Failed to start Java
[2014-02-19 16:40:35] [error] ( prunsrv.c:1536) [ 5000] ServiceStart returned 4

您会注意到启动器存在一些类路径问题.实际上,这就是问题所在!您的service.bat没有正确配置服务:

You'll notice that there is some classpath problem with the starter. In fact that's the problem! Your service.bat didn't configure the service the right way:

注意:您还可以选择"Java虚拟机"上方的使用默认值"以使用JAVA_HOME中定义的任何JVM

Note: You can also choose "Use default" above "Java Virtual Machine" to use whatever JVM is defined in JAVA_HOME

您需要正确设置类路径:

You'll need to set the classpath correctly:

c:\ webclient \ apache-tomcat \ bin \ tomcat-juli.jar; c:\ webclient \ apache-tomcat \ bin \ tomcat-juli.jar; c:\ webclient \ apache-tomcat \ bin \ bootstrap.罐子

c:\webclient\apache-tomcat\bin\tomcat-juli.jar;c:\webclient\apache-tomcat\bin\tomcat-juli.jar;c:\webclient\apache-tomcat\bin\bootstrap.jar

在我的情况下,我在以下位置安装"了tomcat:c:\ webclient \ apache-tomcat用您的替换那一部分.在我的情况下,甚至没有设置Java VM.

In my case i "installed" tomcat at: c:\webclient\apache-tomcat replace that part with yours. In my case not even the Java VM was set.. I'm not shure whether this is a problem with the current versions of tomcat (and it's service.bat), or with some sort of permission problem on the windows server itself..