wood burning stoves 2.0*
The moose likes Servlets and the fly likes Is Tomcat needs to be run everytime the Servlet Changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is Tomcat needs to be run everytime the Servlet Changes" Watch "Is Tomcat needs to be run everytime the Servlet Changes" New topic
Author

Is Tomcat needs to be run everytime the Servlet Changes

Priya Sri
Ranch Hand

Joined: Mar 30, 2004
Posts: 84
Hi friends,

Any solution to the problem that Tomcat needs to be run everytime the servlet has undergone a small change?

If u know, reply.

Bye
Priya.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
You can use the Tomcat manager interface to restart just the web application instead of restarting the entire server.


42
Priya Sri
Ranch Hand

Joined: Mar 30, 2004
Posts: 84
How to use that Tomcat Manager Interface ???
Napa Sreedhar
Ranch Hand

Joined: Jan 29, 2002
Posts: 62
This question should have been answered several times..
Turn on servlet reloadable to true

Refer to the link for Server configuration
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html
Priya Sri
Ranch Hand

Joined: Mar 30, 2004
Posts: 84
For the solution of my problem,

Should I include the following in web.xml file of my specific appln.

<context-path>
<param-name>reloadable</param-name>
<param-value>true</param-value>
</context-path>

Does this solves the problem?
If I am wrong, correct me.

thanks
Priya Sri
Ranch Hand

Joined: Mar 30, 2004
Posts: 84
hi friends,

I added the following in f:\tomcat\server.xml file. and my appln resides in f:\tomcat\webapps\Pams

- <Context path="/Pams" docBase="f:\tomcat\webapps\Pams" debug="9" reloadable="true">
<Loader checkInterval="3" />
<Logger className="org.apache.catalina.logger.SystemOutLogger" timestamp="true" />
</Context>



U can observe that I set reloadable to "true"
But my problem was not solved....
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Originally posted by Priya Sri:
For the solution of my problem,

Should I include the following in web.xml file of my specific appln.

<context-path>
<param-name>reloadable</param-name>
<param-value>true</param-value>
</context-path>

Does this solves the problem?
If I am wrong, correct me.

thanks


Did you try this?


Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Priya Sri
Ranch Hand

Joined: Mar 30, 2004
Posts: 84
Hi vijay,

I tried that and it's worked for the first time when I changed the servlet and without restarting the tomcat....... but when second time I changed the servlet, it is not reflecting the changes done in the servlet.

I compiled the servlet after a small change. I didn' understand the reason.
kumm redd
Ranch Hand

Joined: Nov 02, 2004
Posts: 31
hi
first it depends on the version of tomcat you are using
but this html page addreses all .
http://www.coreservlets.com/Apache-Tomcat-Tutorial/
i would like to point you to specific subsection on this webpage..
just go thru
section 2.3,2.4 and 2.6 and also section 5.1

in brief::
Edit install_dir/conf/server.xml and uncomment this line: <Context path="" docBase="ROOT" debug="0"/>. Not necessary in Tomcat 4.0.3 and earlier. In most versions of Tomcat 5, the element is missing the trailing slash and you need to add it

Edit install_dir/conf/server.xml and add the following just above the entry for the ROOT context from the previous step:
<DefaultContext reloadable="true"/>

Go to install_dir/conf/web.xml (not .../server.xml) and uncomment the servlet and servlet-mapping elements that map the invoker servlet to /servlet/*. In Tomcat 4, you only need to uncomment the servlet-mapping element, and this is not necessary at all prior to Tomcat 4.1.12.

Test a packageless servlet. Compile a simple servlet, put the .class file in install_dir/webapps/ROOT/WEB-INF/classes, and access it with http://localhost/servlet/ServletName.


i tested my app with tomcat 5.0.28 .. it works fine ..

P.s approach mentioned by Jeroen Wenting 1.e, with manager interface is the recommended one compared to the the approach that we were all discussing

for the first time you can test with our approach,but use the second one after you get used with that..

if any doubtss ..lemme know
Priya Sri
Ranch Hand

Joined: Mar 30, 2004
Posts: 84
hi raj,

This is my code in server.xml file and Pams is my appln

<DefaultContext reloadable="true"/>
<Context path="/Pams" docBase="f:\tomcat\jakarta-tomcat-5.0.19\webapps\Pams" debug="0" reloadable="true">
<Loader checkInterval="3" />
<Logger className="org.apache.catalina.logger.SystemOutLogger" timestamp="true" />
</Context>

But it didn't work... not reflecting the changes..
Dark Vachor
Greenhorn

Joined: Oct 13, 2004
Posts: 14
Priya Sri,

You configured Tomcat to reload your app properly, the proof is that it reloaded one time. You say it doesn't reload the second time. Try a third time, or try to "touch" you servlet file. It *may* reload the app. Usually it doesn't, once it's stuck you'll have to relaunch the whole of it.
Apache software is no more the quality one is used to be. It's now very buggy, and bloated, and clunky. Probably as Apache inexperienced programmers believe to be the king of programmers, reinvente the wheel the wrong way, and refuse any critics because they re the bests. At least they should RTFM about Java classes (system libraries), and stop writing useless code. And they should stop make people have to use *their* crappy log4j logger.
 
 
subject: Is Tomcat needs to be run everytime the Servlet Changes