melo
melo

Reputation: 239

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.

Upvotes: 19

Views: 164279

Answers (15)

Charlo Poitras
Charlo Poitras

Reputation: 318

I solved this problem setting the correct JVM path inside the tomcatXw.exe

  1. Locate your Tomcat server installation
    (C:\Program Files\Apache Software Foundation\Tomcat X\bin)
  2. Click tomcatXw.exe
  3. Go to the Java tab
  4. Uncheck use default and be sure that your Java Virtual Machine is set to the correct path.
    (C:\Program Files\Java\jre1.8.0_361\bin\server\jvm.dll) in my case

For more informations check out this

Upvotes: 0

Saffa Seraj
Saffa Seraj

Reputation: 127

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

  1. Start > Control Panel > lookup for the "System"
  2. Choose "Edit the system environment variables"
  3. Select the "Advanced" tab.
  4. Click on "Environment Variables..." button. (bottom of the window)
  5. in the System Variables group box, click on the "New..." button
  6. assign the desired name like "Java_Home"
  7. Click on "Browse Directory" and address your Java jdk directory. ex: C:\Program Files\Java\jdk-13.0.2
  8. go to the Tomcat 'bin' folder and start it up.

Supposed to work now.

Upvotes: -1

Ravi G
Ravi G

Reputation: 11

Solution suggested by Prashant worked fine for me.

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

Upvotes: 1

Jan Hirschkuh
Jan Hirschkuh

Reputation: 3

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.

Upvotes: 0

sabeena kumarawadu
sabeena kumarawadu

Reputation: 165

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

Upvotes: 1

ReL
ReL

Reputation: 11

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.

Upvotes: 1

Prashant
Prashant

Reputation: 641

Go to Start > Configure Tomcat >

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

This worked for me!

Upvotes: 49

Zahi Enix
Zahi Enix

Reputation: 928

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.

Upvotes: 0

Hoque MD Zahidul
Hoque MD Zahidul

Reputation: 11949

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.

Upvotes: 1

Comm4nd0
Comm4nd0

Reputation: 671

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

Upvotes: -1

elin
elin

Reputation: 568

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.

Upvotes: 16

Nitin Mestry
Nitin Mestry

Reputation: 1

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

Upvotes: 0

Nivedita Gopal
Nivedita Gopal

Reputation: 91

"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

Upvotes: 9

KingQQ
KingQQ

Reputation: 293

  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

Upvotes: 1

Anup Ganatra
Anup Ganatra

Reputation: 366

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"

Upvotes: 3

Related Questions