File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet not refreshing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet not refreshing" Watch "Servlet not refreshing" New topic
Author

Servlet not refreshing

Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
I am learning servlets currently and using Tomcat as the servlet engine. Everytime I change something in the source file(*.java) and click the refresh button on the browser, it does not get refreshed. The 'Core Servlets and Java Server pages' book says that I need to restart my mini server and shut it down anytime I change the source.
Is there any other way I can achieve this without shutting down the mini-server and restarting it again to look at my changes that I just made.
Any help would be appreciated.
eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
I don't know about your question, but I think you answered mine!
Thanks, and good luck!
e


<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>"Those who cast the votes decide nothing. Those who count the<BR>votes decide<BR>everything." <BR> -Joseph Stalin<HR></BLOCKQUOTE>
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Tomcat attempts to reload changed classes, but is reputedly not very good at it. A lot of Tomcat users habitually restart the server when things change. I find Resin from http://www.caucho.com to be much more predictable at this, so you may want to consider traying alternatives.
Detection of changes is usually dependent on whether the directories containing the class files are in the "dynamic" part of the classpath which is examined by the server, and also dependent on timestamp differences between class files and source files.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
Hi Frank,
I shall certainly try the Resin server as you suggested.
Also, I would like to know what is the effect of the timestamp difference between the class files and source files.
Thank you for yur input and suggestion..
Chuck
Originally posted by Frank Carver:
Tomcat attempts to reload changed classes, but is reputedly not very good at it. A lot of Tomcat users habitually restart the server when things change. I find Resin from http://www.caucho.com to be much more predictable at this, so you may want to consider traying alternatives.
Detection of changes is usually dependent on whether the directories containing the class files are in the "dynamic" part of the classpath which is examined by the server, and also dependent on timestamp differences between class files and source files.

Kamakshi Mahadevan
Greenhorn

Joined: Nov 08, 2000
Posts: 18
Hi Chuck,
I had a similar problem with server autoreload. If you check the Tomcat Installation known bugs and problems, it states that the servlet auto reload feature is only experimental & not fully functional in Tomcat 3.2. Hence setting reloadable="true" for your application in server.xml does not work.The only way is to restart your server everytime you recompile your servlet in Tomcat.
Kamakshi
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
Servlet Not Refreshing .... ummmmm ... try a twist of lemon. That alway's perks up a glass of iced tea
Sorry, I couldn't resist. I'll go now.
Sean
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Also, I would like to know what is the effect of the timestamp difference between the class files and source files.

None. The source file has nothing to do with reloading of the class.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
Sean,
I should say that I am also laughing at your reply ( cannot resist not laughing)...
Good. light hearted humor taken in good spirit..
Chuck
Originally posted by Sean MacLean:
Servlet Not Refreshing .... ummmmm ... try a twist of lemon. That alway's perks up a glass of iced tea
Sorry, I couldn't resist. I'll go now.
Sean

eric moon
Ranch Hand

Joined: Nov 26, 2000
Posts: 133
Well, I have put tomcatStartup and tomcatShutdown in my start menu, and it's pretty painless now.
Is the resin server freeware??
thanks!
eric
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
OK, maybe in Tomcat the source file timestamp is not important, but Resin (with which I am most familiar) will compile new source files and autoreload the changed classfile as one operation. A few times I have been expecting this to happen but it has been prevented because I was deploying the source file via a shared file system from a machine with a slightly different clock time.
Resin is free for development and non-profit use, or $500 per machine for commercial deployment. Well worth it in my opinion. It's open source and the free support is good, but if you register the software you also get the email "ear" of the developers.
Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
Frank,
Could you tell me how to configure 'Resin'?
Chuck
Originally posted by Frank Carver:
OK, maybe in Tomcat the source file timestamp is not important, but Resin (with which I am most familiar) will compile new source files and autoreload the changed classfile as one operation. A few times I have been expecting this to happen but it has been prevented because I was deploying the source file via a shared file system from a machine with a slightly different clock time.
Resin is free for development and non-profit use, or $500 per machine for commercial deployment. Well worth it in my opinion. It's open source and the free support is good, but if you register the software you also get the email "ear" of the developers.

Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Essentially the process is simple. Download the latest stable executable from http://www.caucho.com and follow the instructions on the site. Is there anything in particular you want to set it up to do?
Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
Frank,
My original intent of starting this thread was to find out if there is a way to do an auto reload of the class files once I change the source code, compile and then copy the class file to the required destination as suggested by the different web servers. When I tried doing this in Tomcat by copying the class file it to the tomcat\webapps\root\web-inf\classes directory, it does not refresh the servlet. I needed to shutdown the servlet server and restart it again. essentially it does not reload it unless I stopped the servlet server. So using Resin, I was hoping to accomplish this. Is there a configuration file that I need to change to acheive the auto reloading of class files when the servlet server is still running instead of stopping it and restarting it again ?
Any input would be appreciated.
Chuck
Originally posted by Frank Carver:
Essentially the process is simple. Download the latest stable executable from http://www.caucho.com and follow the instructions on the site. Is there anything in particular you want to set it up to do?

Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
The supplied installation of Resin will both compile and reload classes by default, or reload them if the class file is newer than the loaded version. Are you having problems making it work?
Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
Yes I am having problems even after I copy the newer *.class file to the resin1.2.1\doc\web-inf\classes\coreservlets directory. (coreservlets is the directory my servlets are placed in -- I am originally compiling them into a coreservlets directory (using a package statement)). So my source files are in d:\myjavafiles and my class files get placed in d:\myjavafiles\coreservlets as 'package coreservlets' is in my source file and while compiling it I request it to place it under d:\myjavafiles directory. And sucessful compilation, I copy the class files to resin1.2.1\doc\web-inf\classes\coreservlets directory as suggested in the configuration. Inspite of doing this I still cannot get the latest servlet.
any suggestions?
Chuck
Originally posted by Frank Carver:
The supplied installation of Resin will both compile and reload classes by default, or reload them if the class file is newer than the loaded version. Are you having problems making it work?

bredan
Greenhorn

Joined: Dec 20, 2000
Posts: 11
The best way is restarting the server.
When you test your java coding, you could change the file names. it works without restarting the server.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I'm a little puzzled why youneed to compile them elsewhere then move the files to the default (doc) web-app used by Resin. Is there a particular reason why you can't put both your source and class files in doc/web-inf/classes directory so it can see what's happening? Or, failing that, compile the files directly into doc/web-inf/classes using your manual compiler or IDE. Both of these approaches have worked for me.
If there is still a problem, please let us know which particular Resin version you are using, and any changes you have made to resin.conf, and I'll check out what it should be doing.
Chuck Meduri
Ranch Hand

Joined: Nov 29, 2000
Posts: 48
The only reason to compile them elsewhere and move the files to the default location used by resin is to keep my source files directory separate from my class files directory. I have manually compiled into the doc/web-inf/classes(using the -d option with the javac compiler from the DOS prompt) and still it does not seem to refresh. I downloaded the Resin 1.2.1 version. I haven't made any changes to the resin.conf file at all.
Originally posted by Frank Carver:
I'm a little puzzled why youneed to compile them elsewhere then move the files to the default (doc) web-app used by Resin. Is there a particular reason why you can't put both your source and class files in doc/web-inf/classes directory so it can see what's happening? Or, failing that, compile the files directly into doc/web-inf/classes using your manual compiler or IDE. Both of these approaches have worked for me.
If there is still a problem, please let us know which particular Resin version you are using, and any changes you have made to resin.conf, and I'll check out what it should be doing.

 
GeeCON Prague 2014
 
subject: Servlet not refreshing