You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Chris Price <ch...@cal.montage.ca> on 1999/12/31 00:49:10 UTC
Reload of Tomcat required when changes made to servlets?
Hi;
Here's my problem;
I have successfully got Tomcat working with Apache: ie: going to
http://<hostname>/examples/
gives me all the examples provided with Tomcat. COOL!
HOWEVER, when I make a minor change to a .java file (eg: the
'HelloWorld.java' example servlet provided), and then recompile using
javac <filename>` , the changes I made are not picked up by
Tomcat-Apache until I STOP and then START the Tomcat process (using the
provided shutdown.sh and startup.sh scripts). Doing a `kill -HUP <tomcat
pid>` just kills the Tomcat process altogether.
Is this the correct functioning of the Tomcat-Apache server pair? I
hope there is a way around this, as with several developers working on a
project debugging code things will get hairy
(debug-change-publish-restart Tomcat-debug-change-publish...).
Again, your help is appreciated...
Chris
Fired up Tomcat for the first time!
Posted by David Brady <Da...@JavaGems.com>.
Hi everyone,
I've been on this list for several weeks, but haven't had the opportunity to try
out Tomcat until today. I have been very excited about this project ever since
Sun's announcement.
I am happy to report that everything installed and ran perfectly. The
instructions are clear and easy to follow. I encountered a small problem due to
not reading carefully enough. However, it was easily solved by examining the
instructions more thoroughly. Only been using linux/unix for 4 months, so this
is a testament to how foolproof you've made this process.
Some minor suggestions for the Apache-HowTo document:
* Remind people who currently have JServ installed to remove the reference to
the old jserv.conf file.
* Emphasize that you must startup Tomcat in addition to Apache, and that the
ApJservManual property isn't implemented yet.
Just wanted to congratulate everyone who is working on this! I hope I can help
out in the future.
David Brady
Here are my system settings:
Tomcat 3.0 from source tree
mod_jserv.so from tomcat/3.0/linux/i386
AMD K6-200/ 128 MB RAM
Linux Mandrake 6.1
Apache/1.3.9
Blackdown JDK_1.2 PRv2, native threads (will try the JIT enabled version from
Inprise soon)
JDBC/PosetgreSQL
Re: Reload of Tomcat required when changes made to servlets?
Posted by "Craig R. McClanahan" <cm...@mytownnet.com>.
Jim Rudnicki wrote:
> > Subject: Re: Reload of Tomcat required when changes made to servlets?
>
> > > That being said, I'm sure this will be a highly requested feature, and
> will
> > > therefore be near the top of the priority list.
> >
> > Probably in Tomcat 4.0?
> >
>
> I can agree that stopping and starting the server is a bit tedious during
> development, but I don't know if it is really better to be constantly
> checking timestamps during normal builds. After all why constantly check
> "has it changed yet...no...has it changed yet...no...has it changed
> yet...no..."
>
The interesting part of implementing reloading is not really the administrative
issue of how do I request it, but rather it's the "what do I do now that it is
time to reload". What you're saying you want to do is replace an existing
class (previously loaded) with a new one. At first blush, the Java language
appears to provide no such mechanism.
The way most servlet engines (including Apache JServ) implement this is that
they provide a custom ClassLoader for all the classes that are subject to
reloading. When you instantiate an instance of a new class for the first time,
the class itself (which is also an object) gets loaded by a class loader, and
then is used to load the remaining classes. At reload time, what you do, in
essence, is throw away your reference to the class loader (which recursively
throws away all references to all classes loaded by that class loader, and all
objects of those classes). Then, you create a new class loader and start
again.
Along the way, you are required (by the 2.2 spec) to avoid class cast
exceptions for the servlets you are loading (class "com.mycompany.Foo" loaded
by one class loader is different from class "com.mycompany.Foo" loaded by a
different class loader). In essence, that boils down to loading all the
classes required for a particular web application from the same class loader.
>
> So I propose this: a development version of Tomcat. If embedding is as
> simple as SimpleStartup.java suggests, then this wrapper's function could be
> expanded just a little to support a remote restart ability. The restart
> would really be a delete and new. And of course a tiny servlet would
> instruct the wrapper to restart. The result http remote restart.
>
It's probably just as easy to provide a configuration switch (for Tomcat you'd
set it in the "server.xml" file) for whether to monitor classes for changes or
not. That way, you don't need to maintain two versions of Tomcat itself.
Even if you do not leave auto-reloading turned off, the idea of being able to
manually request a reload is a really good idea. In a long running server that
is supporting multiple web applications, you don't want to shut them all down
simply because you installed a new revision of one of the apps. You could
signal the manual restart request by extending the existing admin interface, or
by providing a built-in servlet, but don't forget about some sort of security
to avoid "denial of service" attacks by continually asking the application to
reload itself.
>
> I wonder if the resulting server would still operate as a servlet engine for
> Apache. hmmm. Tommorrow is a day off and the bunker doors are getting
> sealed at sunrise. I may give this a whirl.
>
There's no reason that reloading should affect whether or not you can be
connected to Apache. After all, Apache JServ has been doing this for years.
In fact, the custom class loader implementation in the Apache JServ code base
(org.apache.java.lang.AdaptiveClassLoader, at <http://java.apache.org>) would
give you a tremendous head start. It should be useable (in Tomcat) pretty much
as is, and already supports the "automatic reload switch" capability described
earlier.
If you're really going to go after this, you might want to address any future
comments and questions to the TOMCAT-DEV mailing list as well.
>
> Jim
>
Hope everyone has a Happy Y2K Day!
Craig McClanahan
Re: Reload of Tomcat required when changes made to servlets?
Posted by Jim Rudnicki <jd...@pacbell.net>.
> Subject: Re: Reload of Tomcat required when changes made to servlets?
> > That being said, I'm sure this will be a highly requested feature, and
will
> > therefore be near the top of the priority list.
>
> Probably in Tomcat 4.0?
>
I can agree that stopping and starting the server is a bit tedious during
development, but I don't know if it is really better to be constantly
checking timestamps during normal builds. After all why constantly check
"has it changed yet...no...has it changed yet...no...has it changed
yet...no..."
So I propose this: a development version of Tomcat. If embedding is as
simple as SimpleStartup.java suggests, then this wrapper's function could be
expanded just a little to support a remote restart ability. The restart
would really be a delete and new. And of course a tiny servlet would
instruct the wrapper to restart. The result http remote restart.
I wonder if the resulting server would still operate as a servlet engine for
Apache. hmmm. Tommorrow is a day off and the bunker doors are getting
sealed at sunrise. I may give this a whirl.
Jim
Re: Reload of Tomcat required when changes made to servlets?
Posted by Chris Price <ch...@cal.montage.ca>.
>
> All I can do is give you the standard "open source project" answer --
^^^^^^^^^^^^^^^^^^^^^
Having been a long time Apache user and supporter, I would expect that
caveat. :)
> That being said, I'm sure this will be a highly requested feature, and will
> therefore be near the top of the priority list.
Probably in Tomcat 4.0?
Thanks
Chris
Re: Reload of Tomcat required when changes made to servlets?
Posted by "Craig R. McClanahan" <cm...@mytownnet.com>.
Chris Price wrote:
> "Craig R. McClanahan" wrote:
> >
> > Chris Price wrote:
>
> > At the moment, that is the expected behavior. Tomcat 3.0 does not support
> > auto-reloading on class changes -- this is on the list of future enhancements.
> >
>
> Any idea on the timeframe involved? 1 month, 6 months, 12 months? I
> don;t expect an accurate answer, but maybe a 'this is near the
> top/bottom of the `TODO` list' would help. My company would like to
> start using Tomcat extensively, but we see this 'feature' as a
> significant drawback to a productive development environment.
>
All I can do is give you the standard "open source project" answer -- it will be
there as soon as someone contributes the code to do it.
That being said, I'm sure this will be a highly requested feature, and will
therefore be near the top of the priority list.
>
> TIA
>
> Chris
>
Craig
Re: Reload of Tomcat required when changes made to servlets?
Posted by Chris Price <ch...@cal.montage.ca>.
"Craig R. McClanahan" wrote:
>
> Chris Price wrote:
> At the moment, that is the expected behavior. Tomcat 3.0 does not support
> auto-reloading on class changes -- this is on the list of future enhancements.
>
Any idea on the timeframe involved? 1 month, 6 months, 12 months? I
don;t expect an accurate answer, but maybe a 'this is near the
top/bottom of the `TODO` list' would help. My company would like to
start using Tomcat extensively, but we see this 'feature' as a
significant drawback to a productive development environment.
TIA
Chris
Re: Reload of Tomcat required when changes made to servlets?
Posted by "Craig R. McClanahan" <cm...@mytownnet.com>.
Chris Price wrote:
> Hi;
>
> Here's my problem;
>
> I have successfully got Tomcat working with Apache: ie: going to
>
> http://<hostname>/examples/
>
> gives me all the examples provided with Tomcat. COOL!
>
> HOWEVER, when I make a minor change to a .java file (eg: the
> 'HelloWorld.java' example servlet provided), and then recompile using
> javac <filename>` , the changes I made are not picked up by
> Tomcat-Apache until I STOP and then START the Tomcat process (using the
> provided shutdown.sh and startup.sh scripts). Doing a `kill -HUP <tomcat
> pid>` just kills the Tomcat process altogether.
>
> Is this the correct functioning of the Tomcat-Apache server pair? I
> hope there is a way around this, as with several developers working on a
> project debugging code things will get hairy
> (debug-change-publish-restart Tomcat-debug-change-publish...).
>
At the moment, that is the expected behavior. Tomcat 3.0 does not support
auto-reloading on class changes -- this is on the list of future enhancements.
>
> Again, your help is appreciated...
>
One approach to your multi-developer situation would be to have each developer
running their own work in their own instance of Tomcat. For example, if you
had four developers, you would create four mount points (with different names)
-- one for each developer -- using different port numbers. That way, each
developer would only be restarting their own copy of Tomcat, without impacting
anyone else. I'm not sure about the exact syntax for the ApJServMount
directives to do this, but you should be able to find it in the Apache JServ
documentation and FAQ-O-MATIC (at http://java.apache.org).
Another way to deal with this, if you don't need Apache for anything other
than static content, would be to develop under Tomcat stand-alone, again one
per developer. When you're ready to integrate things, you could use the
Apache+Tomcat version. Of course, if you are using other Apache features this
might not be practical.
>
> Chris
>
Craig McClanahan