Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache tomcat7 as windows service

Tags:

java

tomcat

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

I executed this :

C:/tomcat7/bin> service install Mytomcat7

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

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

like image 949
selson Avatar asked Feb 19 '26 14:02

selson


2 Answers

I had the same problem!

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

Log Config

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

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 Config

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.jar

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..

like image 134
Dudelilama Avatar answered Feb 21 '26 04:02

Dudelilama


To solve this error perform the following steps:

  • Run the tomcat7w.exe monitor application found in <TOMCAT_HOME>/bin.
    Tomcat7w is a GUI application for monitoring and configuring Tomcat services.
    If you named your service Mytomcat7 you will need to rename this file to Mytomcat7.exe before running it
  • In the "Startup" tab change the value of "Mode" from jvm to Java
  • Do the same in the "Shutdown" tab
like image 24
Dror Bereznitsky Avatar answered Feb 21 '26 02:02

Dror Bereznitsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!