• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Servlet not refreshing

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know about your question, but I think you answered mine!
Thanks, and good luck!
e
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Chuck Meduri
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Chuck Meduri
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?


 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
reply
    Bookmark Topic Watch Topic
  • New Topic