[java] Can't start Tomcat as Windows Service

I am using Tomcat6 on Windows 8. I am able to start Tomcat via startup.bat without error. I've copied Tomcat6.exe, Tomcat6w.exe and service.bat under tomcat/bin directory and set the .exe files to run as administrator.

I open command line with administrator rights and execute "service.bat install" which ran without error. In Windows Services, I can see Apache Tomcat 6 which I want to run automatically.

But both running from Windows Services using "Start" button and on start up of Windows I got the same error.

"Windows could not start the Apache Tomcat 6 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 0.

When I check Windows Event Log, I see the following bizarre error.

"Apache Tomcat 6 service terminated with the following service-specific error: The operation completed successfully."

I tried copying msvcr71.dll under tomcat/bin directory, but nothing changed. What else can I do?

Update:

I am using a different port than 8080. And I saw the error below in the log file /logs/jakarta_service.log:

%1 is not a valid Win32 application.

This question is related to java windows tomcat windows-services

The answer is


On a 64-bit system you have to make sure that both the Tomcat application and the JDK are the same architecture: either both are x86 or x64.

In case you want to change the Tomcat instance to x64 you might have to download the tomcat8.exe or tomcat9.exe and the tcnative-1.dll with the appropriate x64 versions. You can get those at http://svn.apache.org/viewvc/tomcat/.

Alternatively you can point Tomcat to the x86 JDK by changing the Java Virtual Machine path in the Tomcat config.


  1. Check the apache tomcat catalina log: ../logs/catalina.log
  2. If in the log you find the "port was used" exception, then Check windows used ports and processes with following command: Run cmd netstat -ao it will list all listening ports and corresponding process Id, you can find the port which was used by Tomcat from the configuration file: ../conf/server.xml

    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
    

and kill the process which use the tomcat port


I had the similar issue, But installing tomcat 32bit and jdk 32 bit worked, This happens mostly because of mismatch Bit.


Well before going so far, fist make sure that you have the path to the Java directory in your Windows Environment Path

  1. Start > Control Panel > look up for the "System"
  2. Edit the system environment variables
  3. Click on "Environment Variables..." button.
  4. in the System Variables group box, click one the "New..." button
  5. assign a desired name like "Java_Home"
  6. Click on "Brows Directory" and address your Java jdk directory. ex: C:\Program Files\Java\jdk-13.0.2
  7. go to the Tomcat 'bin' folder and start it up.

Supposed to work now.


I have the problem because I updated Java version.

The following steps work for me:

  1. Run \Tomcat\bin\tomcat7w.exe
  2. Confirm "Startup" tab -> "Mode" choose "jvm"
  3. "Java" tab -> update "Java Virtual Machine" path to new version path
  4. Restart Tomcat

Done.


In my case it helps if you don't install the x86 version over the x64 version... DOH!!!


You need to check the ports first. It might be situation that default port(8080) is used by some other application.

Try changing the port from 8080 to some different port in conf/server.xml file.

Also please check that your JRE_HOME variable is set correctly because tomcat needs JRE to run. You can also set your JRE_HOME variable in system. For that go to my computer->right click and select properties->Advanced system settings->Advanced->Environment variable and click on new-> variable name = "JRE_HOME" and variable value = "C:\Program Files\Java\jre7"


Solution suggested by Prashant worked fine for me.

Tomcat9 Properties > Configure > Startup > Mode = Java Tomcat9 Properties > Configure > Shutdown > Mode = Java


Go to Start > Configure Tomcat >

  • Startup > Mode = Java
  • Shutdown > Mode = Java

This worked for me!


The simplest answer that worked for me was the one mentioned by Prashant, and edited by Bluish.

Go to Start > Configure Tomcat > Startup > Mode = Java Shutdown > Mode = Java

Unfortunately I had(and possibly others) to do this in a different way, I went to the tomcat bin directory and ran the "tomcat7w" application, which is how I changed the configuration.

There I was able to change the startup mode and shutdown mode to Java. Like this:

Step1) Locate tomcat7w:

general location => %TomCatHomeDIR%/bin In my case tomcat was in the xampp folder so my address was:

C:\xampp\tomcat\bin

tomcat7w file location screenshot

Step2) Launch tomcat7w && change the Mode in the Startup and Shutdown tabs

tomcat7w startup tab screenshot

Note >This based on version 7.0.22 that comes standard with XAMPP.


All those mistakes are related to badly connected Apache and JDK.

  1. go to start>System>Advanced_system_settings>
  2. System Properties will pop-up go to Environment Variables
  3. in User variables you have to set variable: JAVA_HOME value: C:\Program_Files\Java\jdk1.8.0_161
  4. in System variables you need to put in the path: jdk/bin path & jre/bin path and also you need to have JAVA_HOME C:\Program_Files\Java\jdk1.8.0_161

people usually forget to setup JAVA_HOME in System variables.

if you still have an error try to think step by step

  1. Open Event viewer>Check Administrative Events and Windows Logs>System see the error. If that doesn't help
  2. go to C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs commons-daemon.XXXX-XX-XX.log and READ THE ERRORS AND WARNINGS... there should be nicely put down in words what's the problem.

Cause :

This issue is caused:

1- tomcat can't find the jvm file from the directory specified to start the service because is deleted.

2- Incorrect permissions to the java folder for read&write access

3- Incorrect JAVA_HOME path.

4- Antivirus deleted the jvm file from java folder

Resolution:

1- confirm that especified file exisit in the java directoy.

2- Make sure that file has read&write permissions.

3- Confirm that JAVA_HOME is correct for java version.

4- if file has been deleted reinstall same java version to recreate missing files.


It is very important that you don't include bin in your JAVA_HOME path. It should be like,

C:\Program Files\Java\jdk-11.0.3


"Windows could not start the Apache Tomcat 6 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 0"

When an error of this sort come. please go to start -> configure tomcat -> startup -> Mode -> java similarly start -> configure tomcat -> shutdown -> Mode -> java


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to windows

"Permission Denied" trying to run Python on Windows 10 A fatal error occurred while creating a TLS client credential. The internal error state is 10013 How to install OpenJDK 11 on Windows? I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? git clone: Authentication failed for <URL> How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" XCOPY: Overwrite all without prompt in BATCH Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory how to open Jupyter notebook in chrome on windows Tensorflow import error: No module named 'tensorflow'

Examples related to tomcat

Jersey stopped working with InjectionManagerFactory not found The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat Spring boot: Unable to start embedded Tomcat servlet container Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists Spring Boot application in eclipse, the Tomcat connector configured to listen on port XXXX failed to start Kill tomcat service running on any port, Windows Tomcat 8 is not able to handle get request with '|' in query parameters? 8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE 403 Access Denied on Tomcat 8 Manager App without prompting for user/password Difference between Xms and Xmx and XX:MaxPermSize

Examples related to windows-services

Can't start Tomcat as Windows Service Error 1053 the service did not respond to the start or control request in a timely fashion How to solve "The specified service has been marked for deletion" error Service will not start: error 1067: the process terminated unexpectedly How to get all Windows service names starting with a common word? Windows service with timer Windows service on Local Computer started and then stopped error Windows service start failure: Cannot start service from the command line or debugger "Automatic" vs "Automatic (Delayed start)" How to install node.js as windows service?