[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Difficulty Restarting Tomcat5

I'm using Linux (Ubuntu 6).  I've never used Tomcat before, so this is my first attempt at deploying a servlet.  I got it up and running fairly smoothly, and deployed an example "HelloWorld" servlet.  However, I noticed that when I modify the servlet class, and then recompile it, the changes I made do not actually take effect when I activate the servlet through a browser.  So, I figured I need to restart Tomcat.  (This is a bit annoying - do you really need to restart Tomcat everytime you make a modification to a servlet class?)

So, there is a daemon launcher script at /etc/init.d/tomcat5.  However, I run into this odd problem where if I stop or restart Tomcat, I can't start it again.  I type "tomcat5 start", and it says that Tomcat is started, but it doesn't actually start - (i.e. no PID is generated), and when I type "tomcat5 status" it tells me that tomcat is not running.  So I need to actually reboot my machine in order to successfully start tomcat again.

Unfortunately, I can't find this problem documented anywhere.  Does anyone have any idea why this might be happening?  Is there another way I'm supposed to be starting/stopping tomcat5?  
2 Solutions
I would suggest reading the Tomcat documenation found at http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html

While restarting tomcat is one way, you can also unload the servet and re-load it while tomcat is running. The understanding is, when you create a servlet, tomcat uncompiles an extracts the servet to run it, therefore when changes are made it needs to be reloaded.
You can also.. just.. "touch web.xml" in WEB-INF directory of web application.. which will cause web application to reload..
First, "tomcat5 start" isn't a valid command unless you have made a highly unusual change to your Linux configuration.  Unlike Windows, Linux doesn't put the current directory on the path.  So it's always "sudo /etc/init.d/tomcat5 start" (or "restart").

Second, it makes sense that Tomcat wouldn't _default_ to automatically reloading changed servlets.  I have two tomcat websites that I haven't even looked at in two years.  Why add the overhead of checking for changes to sites that don't change?  It's just something you need while developing, and they have an option for that (not that I remember what it is :-) ).  Anyway, install the "tomcat5-admin" package, to get a management interface that will allow you to quickly reload apps.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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