Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 37111
  • Last Modified:

Can I run Tomcat as an Service?

as the titile.
I don't want to run the startup script again after reboot the server. Can I set the tomcat as an service so that it can be automaticall restarted after rebooting server machine?
0
ggyao2003
Asked:
ggyao2003
1 Solution
 
JConchieCommented:
Found this....can't vouch for it from experience, but it seems worth a try.

October 3, 2003
Run tomcat as a windows service
October 3, 2003
 If you want to run tomcat as a windows service, there are two ways to do it. Once is while installing choose to install as service, or if you already have installed it through command line, then you can run the following command to install tomcat as a service.

%CATALINA_HOME%\bin\tomcat -install "Apache Tomcat" "%JAVA_HOME%\jre\bin\classic\jvm.dll" -Djava.class.path="%CATALINA_HOME%\bin\bootstrap.jar;%JAVA_HOME%\lib\tools.jar" -Dcatalina.home="%CATALINA_HOME%" -Xrs -start org.apache.catalina.startup.Bootstrap -params start -stop org.apache.catalina.startup.Bootstrap -params stop -out "%CATALINA_HOME%\logs\stderr.log"

The above command will install tomcat as a service. If this fails then its possible that tomcat.exe is not there in %CATALINA_HOME%\bin\ directory. You can just download tomcat again and extract tomcat.exe and put this into the directory. ( I was not having this in my tomcat local directory because when installing for the first time I choose NOT to install it as a service).

After installing the service, you can either go to control panel/administrative tools/services and start and stop the service, or you can run it from command line
net start "Apache Tomcat" // to start the service
net stop "Apache Tomcat" // to stop the service.

If you ever want to uninstall tomcat as a service you can run this command
"%CATALINA_HOME%\bin\tomcat.exe" -uninstall "Apache Tomcat"

Service not starting?
When I did this my service did not start properly, and I went to the event viewer log to see the problem. It was not able to find jvm.dll in the path so I had to search and correct the path for dll and things worked just fine. Note that when I made the path change, i had to first uninstall the service and then install it again.  
0
 
Ryan ChongCommented:
You SHOULD able to make a selection whether you want to make your Tomcat server to run as a Service during the installation, i try Tomcat 4.0.6 and it allow me to select this. And this should apply for the Tomcat version above that.

Another workaround is, try to create a batch file that include the run statement of Tomcat, then put the batch file to run at Startup, do it similarly when you create a new entry to Registry at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

The command of running Tomcat server will be something like:
C:\jdk1402\bin\java.exe -jar -Duser.dir="G:\Tomcat406" "G:\Tomcat406\bin\bootstrap.jar" start

if still not working , try reinstall the Tomcat server, as what JConchie suggested.

regards
0
 
sudev_shettyCommented:
hey the simple way of doind this is ...
there is a installabe called firedeamon download it and install
then add the "%CATALINA_HOME%\bin\tomcat.exe"  to firedeamon
this will be added in the service
as simple as that :)
0
 
sudev_shettyCommented:
sorry i forgot to give u the url of that installer
www.firedaemon.com/downloads/ 
enjoy :)
0
 
ggyao2003Author Commented:
I found that there is an executable file called "service" under /bin directory. I run it in my local machine and reboot, then the tomcat is set as service.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The Lifecycle Approach to Managing Security Policy

Managing application connectivity and security policies can be achieved more effectively when following a framework that automates repeatable processes and ensures that the right activities are performed in the right order.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now