Multiple threads for one submit...how to limit?
I need some good advice: I've got a production app running on a Redhat box that is having problems with the SAN which is causing all processes to slow/stall with heavy IO(CPU util is like 3%); the network/admin guys are working on that part but it's been ongoing. On two occasions during particularly heavy IO, TC 3.x stalls all threads while waiting for the SAN to respond (with file uploading/loading from SAN). Meanwhile a user is submitting a form, which takes too long for their taste, hits stop on the browser and submits again(and again...). I've got code to determine if they've submitted a form already, but that code doesn't get triggered till after the submit is actually handled by my servlet. So it may be 3/4 submits before the locks are finally in place...Any idea how I can lock this down? Isolating TC from SAN is not an option. Thanks in advance, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Equivalent of Resin run-at servlet configuration
Well, I use a servlet that is kicked off at container start(On TC 3.x used load-on-startup attribute, TC 5.x+ there is something else which is now part of the J2EE spec). Most other containers have a load-on-startup type attribute available to them. When that servlet is init()ed at container start I kick off a class which loads more class names out of the web.xml that are Runnable. This parent class then kicks off a thread for each Runnable, and handles making sure they are all reaped when the destroy() method of the servlet is called(usually at container shutdown). There are better ways of doing this now with the newer TC's. If you don't shutdown your child threads, there may be a possibility that they will remain running after TC stops. Good luck. -JW Lionel Farbos wrote: I think that what you want, with this feature, is a daemon (but not a servlet that respond to requests). So, Tomcat don't have to implement anything for this (it's not in its sphere of activities). I think that crons (eventually with httpclients), TimerTasks, ... are more usefull for this need... On Thu, 3 Mar 2005 08:27:46 -0500 Parsons Technical Services [EMAIL PROTECTED] wrote: With all the questions and suggestions flying around, a question to the other programmers: If one was to write a class for the purpose of running classes at set times, what pitfalls would one need to watch for? I have a class that loads on startup and runs a continuous loop that is timed (sleeps, wakes up, does something, sleeps again). It runs fine, but I know that it could be better. Any guidance or suggestions would be appreciated. And maybe we could create an add-on and post it for use in apps that need such a device. Thanks Doug - Original Message - From: Nikola Milutinovic [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Thursday, March 03, 2005 6:55 AM Subject: Re: Equivalent of Resin run-at servlet configuration Subramanya Sastry wrote: Hello, I am developing a Java web application, and one of the requirements is to run a particular servlet periodically, or even at specified times. Resin provides this ability via its run-at configuration element for servlets in web.xml Example Resin configuration: servlet servlet-namedownload/servlet-name servlet-classDownloadNewsServlet/servlet-class run-at period='360m'/ /servlet However, I haven't found an equivalent configuration for Tomcat. I searched the web and was unsuccessful. So, any pointers as to how I could achieve this for Tomcat would be appreciated. There is none and shouldn't be any. I understand the need to run periodical tasks, but J2EE specification, prior to 1.4 has no such provisions. Further, Servlet/JSP specification has no such provision, even in J2EE 1.4. You'd be best advised to setup a cron-job to perform this periodic activity. There are several good HTTP client packages out there, Jakarta-Commons HTTPclient, to name one, that will help you in building the client side of your cron-job. Nix. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Recommendation: where to place app config file without overwriting during deploy. JNDI configuration also??
Okay, lets try this variant of my original post.. I've started using JNDI under 5.0.19 and when I deploy to my remote server(using /Manager) I need to change the data sources url connect string(f/test DB to prod DB). Does everyone use Ant while building the WAR to filter/whatever this url? How do you make changes to the context.xml? Thanks in advance, JW Jonathan Wilson wrote: My current upgrade procedures are to shutdown tomcat 3.x, move the current version of my webapp directory somewhere else, recreate the /webapp directory, then un-jar the war file created by NetBeans. After doing this I then have to modify the WEB-INF/app.config file with customer-specific information. The code is identical, just configuration items change. If the customer has changed their app.config then I have to roll those changes into the new app.config file. Also, I have to copy the log files out of the old version into the new versions' /logs directory and modify the stock log4j.properties to point to their desired directory. Also, I can't always have access to the server to do this so I've written a procedure to explain this to another. Is there a way to store customer configuration info(app.config, log4j.properties) outside of the app and have the app still know how to find it? There must be a better way - nothing in the Tomcat Application Developers Guide that covers this. Thanks in advance, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Updating running WARs?
Someone else will be able to attest to this better than I, but there is a known issue with the classloader [I think] that doesn't release memory on a undeploy..eventually you'll run out of memory after a certain number of deploy/undeploys. You could try using the jvm's -Xmx modifier in your startup/catalina shell, which may buy you more time[guru input here, please]... But my app starts up lightweight so I can schedule downtime a couple of hours or so in advance, then drop tomcat for a few minutes while I deploy manually. Maybe you could use the Manager: Stop the Service, undeploy, stop TC, start TC, deploy the service using the Manager, start service if necessary. Just my .02 For more info search the archives...it's come up more than a few times since I've been on this list. --Jonathan Wendy Smoak wrote: From: David Wood [EMAIL PROTECTED] are we forced to remove the context via the manager and then re-add a new context back in? (Or restart Tomcat?) This is how I've always done it-- remove and install. (For added fun... I removed and installed a webapp repeatedly yesterday, and after about the sixth time, Tomcat died with an OutOfMemory error. Has anyone else had this happen? I chalked it up to the JVM on HP-UX being weird again, but decided to avoid doing that on the production server in the future.)
Where / How to place app config file without overwriting during deploy
My current upgrade procedures are to shutdown tomcat 3.x, move the current version of my webapp directory somewhere else, recreate the /webapp directory, then un-jar the war file created by NetBeans. After doing this I then have to modify the WEB-INF/app.config file with customer-specific information. The code is identical, just configuration items change. If the customer has changed their app.config then I have to roll those changes into the new app.config file. Also, I have to copy the log files out of the old version into the new versions' /logs directory and modify the stock log4j.properties to point to their desired directory. Also, I can't always have access to the server to do this so I've written a procedure to explain this to another. Is there a way to store customer configuration info(app.config, log4j.properties) outside of the app and have the app still know how to find it? There must be a better way - nothing in the Tomcat Application Developers Guide that covers this. Thanks in advance, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Servlet static variable not accessible from init() ??
I'm setting a servlets private static variable from within itself via the contextInitialized(SCE) method but it's not accessible from the init() method once that get's called...I would have thought the static part would make that variable accessible to all thread of the servlet that was started...or is something else going on? Any help is appreciated. public class controller extends HttpServlet implements ServletContextListener { private static Logger cblog = null; public void init() { System.out.println(cblog=+cblog); } public void contextInitialized(ServletContextEvent sce) { cblog = Logger.getLogger(cb); System.out.println(cblog=+cblog); } snip } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Servlet static variable not accessible from init() ??
Thanks for responding. I modified the init() method of the servlet to redo everything that was being done in the contextInitialized() method to workaround the problem. The Listener was getting fired. A while after that NetBeans 'ran out of memory' so I restarted it. Now, after commenting out the workaround, I am unable to duplicate this problem. cblog is always set in the init() method now (like I was expecting). I'll leave the workaround code commented out just to see if my problem returns later. (Note to self: weird behaviour == restart IDE) By store in application scope you mean: getServletContext().setAttribute(string, object) right?? This is then accessible via (object)getServletContext().getAttribute(string) and/or if the object had static fields set they would still be set and accessible via objectclassname.ipublic static string object.getSetting()/i Thanks again for responding, JW QM wrote: On Mon, Jan 17, 2005 at 04:08:15PM -0600, Jonathan Wilson wrote: : I'm setting a servlets private static variable from within itself via : the contextInitialized(SCE) method but it's not accessible from the : init() method once that get's called...I would have thought the static : part would make that variable accessible to all thread of the servlet : that was started...or is something else going on? Any help is appreciated. I didn't look all that closely for the bug itself, but this line caught my ele: : public class controller extends HttpServlet implements : ServletContextListener { Any reason you're putting both in the same class? You could have one ContextListener class instantiate a variable and store it in Application scope; then, the servlet could retrieve it in its init() method. (Be sure to use the init( ServletConfig ) overload in that case.) Are you sure the ContextListener is being fired? (i.e. that it's been properly registered?) Another question: I don't have the JavaDoc in front of me, but does ContextListener (or any of its parent classes) have an init() method? -QM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Where / How to place app config file without overwriting
My current upgrade procedures are to shutdown tomcat 3.x, move the current version of my webapp directory somewhere else, recreate the /webapp directory, then un-jar the war file created by NetBeans. After doing this I then have to modify the WEB-INF/app.config file with customer-specific information. The code is identical, just configuration items change. If the customer has changed their app.config then I have to roll those changes into the new app.config file. Also, I have to copy the log files out of the old version into the new versions' /logs directory and modify the stock log4j.properties to point to their desired directory. Also, I can't always have access to the server to do this so I've written a procedure to explain this to another. Is there a way to store customer configuration info(app.config, log4j.properties) outside of the app and have the app still know how to find it? There must be a better way - nothing in the Tomcat Application Developers Guide that covers this. Thanks in advance, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Where / How to place app config file without overwriting
My current upgrade procedures are to shutdown tomcat 3.x, move the current version of my webapp directory somewhere else, recreate the /webapp directory, then un-jar the war file created by NetBeans. After doing this I then have to modify the WEB-INF/app.config file with customer-specific information. The code is identical, just configuration items change. If the customer has changed their app.config then I have to roll those changes into the new app.config file. Also, I have to copy the log files out of the old version into the new versions' /logs directory and modify the stock log4j.properties to point to their desired directory. Also, I can't always have access to the server to do this so I've written a procedure to explain this to another. Is there a way to store customer configuration info(app.config, log4j.properties) outside of the app and have the app still know how to find it? There must be a better way - nothing in the Tomcat Application Developers Guide that covers this. Thanks in advance, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: WAR files and Eclipse
I tried eclipse, but man was it hard to get configured properly. I wanted to use Eclipse/MyEclipse since I do Perl/C/C++ work as well and thought one tool that binds them all, yada yada yada. I then tried NetBeans and it worked for my environment 'out-of-the-box'. It took zero configuration for me. I just pointed it at my existing source tree and it built its environment and ant scripts accordingly. I really like all of it's editors/interfaces better as well. I would rather use 2 tools (NetBeans for java stuff, and eclipse(or my older editor) for everything else) than jump through Eclipses' hoops for java/J2EE stuff. Your mileage may vary. --JW Phillip Qin wrote: It is very easy. Use ant's war task. -Original Message- From: Daniel Watrous [mailto:[EMAIL PROTECTED] Sent: December 13, 2004 3:44 PM To: [EMAIL PROTECTED] Subject: WAR files and Eclipse Hello All, I am new to WAR files and eclipse. Many searches on google bring me to the sysdeo tomcat plugin, which I have installed. I want to know if there is some standard way to generate a WAR file for deployment. I have found that I can export a JAR file and change its name, but in the process the directory structure is altered. Maybe you even know about a better IDE than eclipse for working with web-based projects. THANKS in advance. Daniel !DSPAM:41bdff16171791264215269! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing/Development environment setups..
Thanks for all the good advice before(everyone) - now more of a specific Web-App Development item: I'm setting up my CVS repository structure(/etc,/src,/lib,/web) per the TC3.3.1 Developing Application with Tomcat FAQ - but the structure is different for TC5.0. And MyEclipse and Netbeans both seem to use a different Web-app structure as well when importing/creating projects. I prefer NetBeans over MyEclipse, and NB does have a free-form project that might work with the TC3.3.1 source setup but the instructions talk about having to rewrite a lot of the default Ant targets(there are like 40 or so) to enable build/test/deploy Automation and the reason I wanted to use an IDE was to *increase* my efficiency. Also, what would happen when someone else on the project had a different IDE preference? So I guess the question(finally) is: How does everyone setup their CVS repositories(diff for each TC target, rebuild repos when TC target changes it's recommendations, change to suit the IDE?) to get over this hurdle? Thanks in advance, JW Tim Funk wrote: There should be no reason you are not able to do all your development on a windows laptop. That being said ... here's how we do things ... When possible all code is written and compiled on our Windows laptops. If anyone wants to look at the latest revision of code - they need to run it off their laptop. For developer integration testing - all the code is tagged (in CVS) by the configuration manager. (CM) (An alternative fancy word for release manager) The CM tags the appropriate files for the development sandbox. From there developer integration testing may occur. This environment is built entirely from verion control. Files do not enter this environment unless they went through CVS. For QNA work the CM will once again tag the files to be able to our QNA environment. Here is where the users test. We actually have 2 QNA environments running off the same source code base. Why 2? Because one QNA instance points to a development database while the second instance points to a replica of the production database. Two databases (still not counting production) are needs since some QNA testing cannot be done without changing the production database first (where the changes get replicated back to the TEST database). Once acceptance testing is done - we have a staging environment. (Code gets here the same way, tag in CVS then build from source) This is a mirror image of the production server except for the database pointing to a replica of the production database(same one that QNA points to). This is a mirror image! If we ever get a bug report against production - we should be able to reproduce it in staging. (This allows us to make changes - confirm there are OK in a staging sandbox and reliably move them to production). Then we have the production box. Each instance above is its own dedicated tomcat - where each tomcat could be a different version if needed. (Think about your upgrades) If you hae enough memory available you can easily run your dev, 2 qna, and staging instances on the same machine. Unless you have a lot of developers and a lot of testers - the load on that box is not going to be high. This also assumes your databases are different machines too. Running a database and application server on the same box is a quick way to run out of resources. So in summary, before code makes it to production it can be tested in the following environments: - Laptop - dev - developer integration - qna1 (dev database) - qna2 (production database replica) - staging It sounds like a lot of environments and a lot of paperwork but CVS + ANT plus a shared build philosphy makes this very manageable. -Tim Jonathan Wilson wrote: This is a general How do you develop a webapp with tomcat/ant with a different development/production server I'm trying to setup my development environment so that I have a development version of my webapp, and a production version of my webapp. My webapp has corporate-wide responsibilities(in a 24-7 environment) and requires very little downtime. Up to now I've managed to do development tasks on the running version(with a few hickups), but I need to start making larger feature changes that I can fully test, without restarting the server and kicking everyone with a session off the system while doing their work. I now understand how ant can help me deploy for different targets, but how do I develop code and test it(without producing all the notification emails, updates to the database, etc) in my development-server and then turn this debug code off in the production-server when it's deployed? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
Re: Form-based login question - explicit login
There's probably a much better way, but I like the fine-grained approach I use. Unfortunately(or fortunately) it requires *every* page you want access controlled to have a jsp:include tag. The included jsp file checks a session variable to determine if the user is logged in, and whether or not their 'role' is sufficient(my app-defined roles, not to be confused with the role mechanism contained within Tomcat itself) to access the resource - so the jsp:included page either forwards them to login page, notifies them they don't have the necessary priviledges, or lets them pass through. For the proper jsp:forward after the user successfully logs in (or if s/he already has the proper perms) I just check a calling parameter which I set from the original calling page(which is properly URL encoded) and jsp:forward the user to that resource. You should check for null forwarding parameters in case the access controlled page doesn't actually set it's forward address properly(well worth your time). Probably a confusing process, but it makes sense to me! ..and it's working on a large-scale in-house production app - their are performance issues I'm sure if your considering a super-large deployment. If anybody has a better/quicker solution I'm interested. --JW footh wrote: I have a quick question regarding Tomcat's form-based login. I have it working fine for pages that are listed as protected. For ex, if a user hits a protected page, they are redirected to a login page, we'll call it login_required that says the requested resource requires a login. If they fail the login, the error page, we'll call login_invalid, appears which looks just like the login_required page except it says invalid login, please try again. If the user logs in correctly on any of these pages, they are redirected to the original protected page. This works great. But, the user can explicitly log in by clicking on a log in link everywhere on the site. I have a an idea of how to do this, but I have a couple of questions regarding this idea. I was going to create a login_dummy page, a protected page that is the source of all the login links throughout the site. When this page is hit, the whole forms-based login process will occur. When the user finally authenticates, the login_dummy page will just redirect them to the home page. The questions I have are 1) I would really like to direct the user to the page they were on when they clicked the login link. I can't figure out how to do that. And 2) This method requires that I use the login_required page described above (the form attached to the form-based login) which will contain text like the requested resource requires a login, etc, etc. When they click on a login link, they aren't accessing a protected resource, they are just logging in. So, I really need a different login page (or just different introductory text). However, I don't know how to differentiate that I'm coming from a direct login link. The latter issue isn't a big deal, I could always just use a generic login page. Anyway, does anyone have any ideas of how I might be able to implement this? Thanks, JF __ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Response and file downloads
Just an FYI: I was unable to get the body onLoad() to work properly on both IE5 and Mozilla - forget exactly why but it was supposed to work! Anyway, I instead used an IFRAME (internal frame) which I added to my forms' output stream(the same form the user just clicked submit() on - essentially a reload with new status information updated and a tad-bit-o-extra-output). The little-bit-o-code is below: iframe name=thisIFRAME id=thisIFRAME src=get_doc?key_id=1668 frameBorder=0 width=0 scrolling=no height=0/iframe This creates a hidden(I don't want to argue the metaphysical side of this) window which in effect 'clicks' on the link I created. Works nicely...so far. I'm not a HTML/Javascript guru so I can't tell you how long this trick will work. Good luck --Jonathan Justin Ruthenbeck wrote: At 12:17 PM 11/1/2004, you wrote: I am not sure what you are refering to as atypical or robustness... I meant to say that you could approximate the behavior you were asking for (dual response), but doing so would be hackish. How do other sites generate files on the fly (take it out of a database, or a report just run), on form submit, and send them down the line and not run into this problem? Like fzlists said, you'll see most sites load a page in response to a download request which either provides a link which the user can click on to download the binary content (right click, save as in IE), or that scripts the browser to automatically begin downloading. This is how CNet, Yahoo, and others do this. I see many people posting many places on the net that they are using the response to send a file, a lot of them are getting this IllegalState, but I never really found a followup solution that really fit my needs. Why would the possibility exist to push a file through the response if it leaves you with the ability to go nowhere after? If your browser submits a request and the response is a mp3 (through either URL inspection or Content-Disposition header), the browser will prompt the user to Save/Open/Run/whatever the file (and won't try to display it). Once the file has been saved, it will leave you at the original page from which the file was requested. Point being that after you push binary content through the response, it leaves you with whatever the previous page's options were ... there's really no contradiction in doing so. justin -Original Message- From: Justin Ruthenbeck [mailto:[EMAIL PROTECTED] Sent: Monday, November 01, 2004 2:56 PM To: Tomcat Users List Subject: Re: Response and file downloads Luc, At 11:42 AM 11/1/2004, you wrote: I am having a wee problem with using the response. I have a form on a page, with a submit button to download a file. That file is being pulled from a database and pushed to the response. The problem I am having, I just used that response to submit the page, so I am getting and IllegalStateException, even though it is still pushing the file to the browswer I also want to be able to send a redirect after the file is downloaded (so I can refresh the page so the form submit page is regenerated, since we are using a string to determine unique submits are only coming from the pages we generated, and not the browser address bar) Can we get a new response from the session variable (the one available to jsp writing) to send the file, then get another new response to perform a redirect Basically I want to be able to do something like the form submits, and passes to the applications perform methods through the jsp catching the submit response = new Response response.sendFile response = new Response response.sendRedirect (yes I know those are not actual methods and classes, just trying to explain what I want) Your understanding of how, exactly, the http protocol works is incorrect. Because it is a (single) request, (single) response protocol, what you're asking for cannot be done. It seems like what you want is for a user to fill out a form, click submit, then be presented with a new, fresh, form again ... with the file download on the side. If you have determined that you absolutely want this behavior (it's atypical, so doing it won't be particularly robust), consider programmatically opening another browser window on form submit from which the download will happen ... and reload your form in your main browser window. This will, of course, subject you to any headaches associated with javascipt window opening. justin __ Justin Ruthenbeck Lead Software Engineer, NextEngine Inc. justinr - AT - nextengine DOT com Confidential. See: http://www.nextengine.com/confidentiality.php __ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For
Testing/Development environment setups..
This is a general How do you develop a webapp with tomcat/ant with a different development/production server I'm trying to setup my development environment so that I have a development version of my webapp, and a production version of my webapp. My webapp has corporate-wide responsibilities(in a 24-7 environment) and requires very little downtime. Up to now I've managed to do development tasks on the running version(with a few hickups), but I need to start making larger feature changes that I can fully test, without restarting the server and kicking everyone with a session off the system while doing their work. I now understand how ant can help me deploy for different targets, but how do I develop code and test it(without producing all the notification emails, updates to the database, etc) in my development-server and then turn this debug code off in the production-server when it's deployed? Any hints/suggestions are appreciated. --Jonathan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing/Development environment setups..
Yoav, Ben: Thanks for the tips - I think I finally have a grasp on how a real project would be run properly. I already use MySQL, cvs(in a manual fashion), ant(still new) so I'm not that far away. Development Box Question: Is it *inadvisable* to do the development using the same tomcat version, ant and a local mysql database on a Windows XP box versus the production server which is a linux box? I'd like to start using an real IDE(Eclipse or Netbeans) and having everything on my XP box sounds doable. Thanks for all your help. --JW Ben Souther wrote: My 2 cents: If your not already using a revision control system, you might want to look into one, like CVS. There are a few books on CVS here: http://jakarta.apache.org/site/library.html BTW: Ant integrates nicely with CVS On Thu, 2004-10-21 at 15:39, Shapira, Yoav wrote: Hi, I now understand how ant can help me deploy for different targets, but how do I develop code and test it(without producing all the notification emails, updates to the database, etc) in my development-server and then turn this debug code off in the production-server when it's deployed? There are several approaches, but the principles tend to be similar: Have complete separate dev, test, and production servers. Dev is local to each developer, quick/small, unstable. Test is as similar to production as possible in configuration and capacity, and used for integration testing, performance testing, QA. Production is production ;) Anything that's environment-sensitive goes in a configuration file, never hard-coded. Ant's filter/token mechanism is great for substituting environment-specific entries when you're creating a WAR of your app and/or deploying to dev/test/production. See the filter ant task reference. For logging, use a real toolkit like log4j instead of System.out or ServletContext#log. Then you can control the logging levels easily at runtime or packaging/deployment time, whatever you feel like. If you configure logging from a file, you can use Ant filter tokens again in this file. Updates to the database are part of testing: the advice about separate Tomcat instances for dev/test/production applies to databases as well. You're good about portability, right? If so, you can use a tiny and free MySQL or HSQL DB in development. Yoav This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing/Development environment setups..
Matt, Ben: Thanks for the additional information - I'm looking forward to setting up my separate development environment tonight. I appreciate everyones comments and suggestions. BTW, I assume if you make schema changes to your development mysql instance you manually implement(ALTER TABLE etc.) those changes in the production database during the deploy process, yes? --Jonathan Ben Souther wrote: On Thu, 2004-10-21 at 17:42, Matt Bathje wrote: Jonathan Wilson wrote: Yoav, Ben: Thanks for the tips - I think I finally have a grasp on how a real project would be run properly. I already use MySQL, cvs(in a manual fashion), ant(still new) so I'm not that far away. Development Box Question: Is it *inadvisable* to do the development using the same tomcat version, ant and a local mysql database on a Windows XP box versus the production server which is a linux box? I'd like to start using an real IDE(Eclipse or Netbeans) and having everything on my XP box sounds doable. Thanks for all your help. --JW I can't help with what is advisable or not, but I can tell you that this is exactly what I do with very few problems. My development machine is Windows with local mysql/tomcat/ant/etc. (and eclipse) while my test/live environments use linux. The one thing I do make sure of is that the versions of mysql/tomcat/ant/jdk/etc. all match between my dev machine and my test/live environments. Matt For us, it is advisable because we ship our app to customers who run it in different environments. Developing, and testing on multiple OSs helps to insure that there are no platform dependent bugs in there. I'm doing the opposite though - developing on a Linux workstation and QAing on a windows box. I would guess that the majority of J2EE apps are developed on windows boxes and then tested and deployed on Unix/Linux. I would advise getting your test environment and your production environment as close to identical as possible. -Ben - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Testing/Development environment setups..
Tim, Thanks for the info, very enlightening. This full process sounds like something I could work up to - I like the multiple checks(env tests). I could remove dev/qna1(presumably since I'll do that stuff during my dev), but qna2 staging are great ideas that I'd not considered. I could really hammer away at the production database and check results/debug without actually impacting everyone who's using the system! --Jonathan Tim Funk wrote: There should be no reason you are not able to do all your development on a windows laptop. That being said ... here's how we do things ... When possible all code is written and compiled on our Windows laptops. If anyone wants to look at the latest revision of code - they need to run it off their laptop. For developer integration testing - all the code is tagged (in CVS) by the configuration manager. (CM) (An alternative fancy word for release manager) The CM tags the appropriate files for the development sandbox. From there developer integration testing may occur. This environment is built entirely from verion control. Files do not enter this environment unless they went through CVS. For QNA work the CM will once again tag the files to be able to our QNA environment. Here is where the users test. We actually have 2 QNA environments running off the same source code base. Why 2? Because one QNA instance points to a development database while the second instance points to a replica of the production database. Two databases (still not counting production) are needs since some QNA testing cannot be done without changing the production database first (where the changes get replicated back to the TEST database). Once acceptance testing is done - we have a staging environment. (Code gets here the same way, tag in CVS then build from source) This is a mirror image of the production server except for the database pointing to a replica of the production database(same one that QNA points to). This is a mirror image! If we ever get a bug report against production - we should be able to reproduce it in staging. (This allows us to make changes - confirm there are OK in a staging sandbox and reliably move them to production). Then we have the production box. Each instance above is its own dedicated tomcat - where each tomcat could be a different version if needed. (Think about your upgrades) If you hae enough memory available you can easily run your dev, 2 qna, and staging instances on the same machine. Unless you have a lot of developers and a lot of testers - the load on that box is not going to be high. This also assumes your databases are different machines too. Running a database and application server on the same box is a quick way to run out of resources. So in summary, before code makes it to production it can be tested in the following environments: - Laptop - dev - developer integration - qna1 (dev database) - qna2 (production database replica) - staging It sounds like a lot of environments and a lot of paperwork but CVS + ANT plus a shared build philosphy makes this very manageable. -Tim Jonathan Wilson wrote: This is a general How do you develop a webapp with tomcat/ant with a different development/production server I'm trying to setup my development environment so that I have a development version of my webapp, and a production version of my webapp. My webapp has corporate-wide responsibilities(in a 24-7 environment) and requires very little downtime. Up to now I've managed to do development tasks on the running version(with a few hickups), but I need to start making larger feature changes that I can fully test, without restarting the server and kicking everyone with a session off the system while doing their work. I now understand how ant can help me deploy for different targets, but how do I develop code and test it(without producing all the notification emails, updates to the database, etc) in my development-server and then turn this debug code off in the production-server when it's deployed? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Load-on-Startup child-threads not dying at context-reload
Great ideas Yoav. Thank you for your comments/input. --JW Shapira, Yoav wrote: Hi, Hmm, then is there a recommended way for managing child threads that are kicked off by a servlet? My servlet reads an XML file to determine what classes to create and run - but if the Servlet itself goes away and then is re-init()ed it will attempt to start those classes again. Does every Runnable child class need to implement Singleton or should I add something to the servlets destroy() method to attempt to close each child before exit? If one of the child threads were busy or locked... You don't need to apply the singleton pattern to each thread or Runnable. But you do need to explicitly interrupt() and null them out on exit. If you start a thread in a servlet's init method, its destroy method is probably the best place for shutting it down. If you start the thread in a ServletContextListener's contextInitialized method, its contextDestroyed method is the best place to do it. As long as you get the basic point, which is that JVM exit != context reload, you'll be OK. Yoav This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Load-on-Startup child-threads not dying at context-reload
I have a load-on-startup1/load-on-startup Servlet on TC3.3.1(under RH7.3) which checks an XML file which contains a list of Runnable classes to kick off at servlet startup. These child threads all belong to the same threadgroup(however, not the same threadgroup of the spawner servlet). These are daemon threads, and have the setDaemon(true) set for the thread before I kickoff the runnable class. The problem I'm experiencing is that when the context needs to be reloaded these child threads are not killed, but continue to run. Since the context was reloaded more threads of the same classes are kicked off - voila, multiple threads responsible for the same thing(not desirable). I don't think I can do a Singleton-type-thing since these old threads seem to be running under a different JVM(via ppid) after context reload. I thought that when only threads of Daemon type were left an application/parent thread would die. I could of course implement an interface which requires a yourDead() method and update all the child classes to check to see if they should exit their infinite loops but I was hoping there was a more elegant way. Better design/good ideas?? Thanks, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Load-on-Startup child-threads not dying at context-reload
I'm working on getting the next release out on TC5. I don't think that would fix my threading issue, however. JW Ben Souther wrote: If upgrading Tomcat is possible, a context listener would be a better design. On Mon, 2004-10-18 at 15:51, Jonathan Wilson wrote: I have a load-on-startup1/load-on-startup Servlet on TC3.3.1(under RH7.3) which checks an XML file which contains a list of Runnable classes to kick off at servlet startup. These child threads all belong to the same threadgroup(however, not the same threadgroup of the spawner servlet). These are daemon threads, and have the setDaemon(true) set for the thread before I kickoff the runnable class. The problem I'm experiencing is that when the context needs to be reloaded these child threads are not killed, but continue to run. Since the context was reloaded more threads of the same classes are kicked off - voila, multiple threads responsible for the same thing(not desirable). I don't think I can do a Singleton-type-thing since these old threads seem to be running under a different JVM(via ppid) after context reload. I thought that when only threads of Daemon type were left an application/parent thread would die. I could of course implement an interface which requires a yourDead() method and update all the child classes to check to see if they should exit their infinite loops but I was hoping there was a more elegant way. Better design/good ideas?? Thanks, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Load-on-Startup child-threads not dying at context-reload
Hi, Shapira, Yoav wrote: Hi, servlet). These are daemon threads, and have the setDaemon(true) set for the thread before I kickoff the runnable class. The problem I'm experiencing is that when the context needs to be reloaded these child threads are not killed, but continue to run. Why would they be killed? The JVM kills daemon threads on exit, and a Tomcat context reload is not a JVM exit. think I can do a Singleton-type-thing since these old threads seem to be running under a different JVM(via ppid) after context reload. They're not running under a different JVM, and ppid on your system is not a reliable method, as has been discussed on this list numerous times. Better design/good ideas?? A ServletContextListener is better, as someone else said, because a load-on-startup servlet may be restarted by the container as needed with or without an application reload. But aside from that, your design reliance on a JVM exit is a basic flaw and upgrading to a later Tomcat version won't help you there. Hmm, then is there a recommended way for managing child threads that are kicked off by a servlet? My servlet reads an XML file to determine what classes to create and run - but if the Servlet itself goes away and then is re-init()ed it will attempt to start those classes again. Does every Runnable child class need to implement Singleton or should I add something to the servlets destroy() method to attempt to close each child before exit? If one of the child threads were busy or locked... Yoav This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Thanks, JW
Re: Tomcat 5 pause (free gmail account for fix :-)
I have a similar problem(TC 3.3.1) but it is related to our pooling solution running out of connections and/or it trying to reap not-checked-in connections. The lockups users reported were during a reap cycle. After a few seconds up to a minute(sound familiar) it would go away and the app would start servicing requests again(checkout netstat -a and count your connections before and after your hicup). It only happens when someone hits the place where I didn't checkin enough times to deplete the pool. I'm feverishly trying to finish implementation so as a bandaid I've increased my pools depth to 100 connections for alpha testing...working for now. Question: Anyone have any ideas on how to track what/where a checkout doesn't get checked-in(better pooling solution? I'm using bitmechanic now). What benefits does TC 4/5 built-in pooling mechanism have over my current solution? Also, when my TC ran out of memory(out of Resources Exception) I just increased the Heap size using TOMCAT_OPTS=$TOMCAT_OPTS -Xmx300m placed in the tomcat.sh script(TC 3.3.1 remember) and it's never happened again(no object loitering, just lots of objects!). If you grow too large(and/or never stop growing!) I'd look into indirectly referenced objects..here's a link to an article about this behavior(good performance analysis info): http://www.opensourcetutorials.com/tutorials/Server-Side-Coding/Java/java-garbage-collection-performance/page4.html --Jonathan Sam Gallant wrote: Everyone, Thanks in advance for any help. Also I have a gmail invite for the person who has a fix for this if they are interested. My company has been using Tomcat for several years, but a problem has crept up that we have not been able to solve. Basically, tomcat will stop processing requests for 2-60 second period several times a day. Here is a list of software that we have tried. (Note we have tried changing each key componant to see if we isolate the componant that is the problem, but no luck yet) OS: RedHat 9 AS3 Threading model: linux threads nptl JVM: sun 1.4.2_4 latest ibm Http connector: ajp w/apache 2 and coyote connector JBDC connector 1.0 1. Doesn't always happen durning old gen garbage collection, but does sometimes 2. Before switching to incremental gc we received out of memory errors which resulted in Tomcat completly hanging 3. After switching to incremental gc the effect changed to 2-60 second periods of time that Tomcat won't process request, but it does resume on its' own. 4. Cpu usage for most of the day is less than 20% utiliztion, but when the problem occurs the cpu spikes to 100% utiliztion briefly. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
mandatory packages for beans in Tomcat 5.0?
I'm evaluating TC 5.0 on Windows XP, coming from TC 3.3.1 on RH7.3. I can't get TC 5.0 to recognize any beans I put in the WEB-INF/classes directory(windows perms all good). If I put the bean into a package and create the proper subdirectory under WEB-INF/classes/ it sees the bean. I don't have to use a package in TC3.3.1 - is this something new or ??? Thanks, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: mandatory packages for beans in Tomcat 5.0?
Thanks to Larry and Yoav. I'm sorry that I didn't search hard enough(TC FAQ. duh!) and asked such a simple question. :) --JW Shapira, Yoav wrote: Hola, http://jakarta.apache.org/tomcat/faq/classnotfound.html Yoav Shapira http://www.yoavshapira.com -Original Message- From: Jonathan Wilson [mailto:[EMAIL PROTECTED] Sent: Thursday, October 14, 2004 4:27 PM To: Tomcat Users List Subject: mandatory packages for beans in Tomcat 5.0? I'm evaluating TC 5.0 on Windows XP, coming from TC 3.3.1 on RH7.3. I can't get TC 5.0 to recognize any beans I put in the WEB-INF/classes directory(windows perms all good). If I put the bean into a package and create the proper subdirectory under WEB-INF/classes/ it sees the bean. I don't have to use a package in TC3.3.1 - is this something new or ??? Thanks, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reloading JSP files without reloading classes/beans
Bob, thanks for all the good pointers. This is just the information about web-app development I've been needing but didn't know how to find(or what to look for). I've played with ANT a bit before, but I didn't know there was an applet to do the deployment for me(is that process portable to diff web-app servers?). I've got the same problem with session retention after a reload(if contexts' reloadable=true that is) - and it sounds like it will still be a problem after I upgrade my development practices and start using WARs. Since you seem like a free thinker :) do you have any ideas on a solution for that problem? I was researching load-balancing Monday and came across a solution that mentioned sessions were retained on a different instance of tomcat(but were accessible to all, somehow - too much for me to digest); perhaps that will provide a path? Here's the link: http://www.onjava.com/pub/a/onjava/2004/04/14/clustering.html Regards, JW Robert Bateman wrote: On Mon, 2004-10-11 at 18:27, Jonathan Wilson wrote: Bob, You just answered my follow up to your previous email :) Hmm, so I run a concurrent version of my production app(being careful not to impact the databases) either on a different instance of Tomcat or just a different context within the same instance of Tomcat. Yes. I use a tool called ANT to process, build and deploy my applications via WAR files. In my ANT build file, I have separate tasks that deploy to production and test. Because I am deploying using a WAR file, each application has it's own configuration file (server.xml) called context.xml. In my case, I have two different configuration files - each specifically tailored to the environment I will deploy into. All my ANT task does is copy the appropriate config during the build. Then when I'm ready I package up the source code into a WAR(what tool do I use for that? - must do research), copy it into the production servers You build the WAR file with a program called JAR. WAR files are zip files with different extensions (in fact, you can rename a WAR file to .ZIP and open the file for inspection.) As you build the WAR file, you want to compile any source modules that need compiling and place them into WEB-INF/classes. JAR files go into WEB-INF/lib so that the WAR file is self contained. webapps directory(and hopefully have all the configuration set properly If your version of Tomcat supports it, instead of copying into the WEBAPPS folder, you can use the manager applets' UNDEPLOY/DEPLOY capability. This allows the server to take your WAR file and put it into the appropriate place on the server. Under TC 4.1 and newer, I've been using a task in ANT that communicated with the manager applet for me and does all of the un/deploying - quite spiffy. to auto-expand) and then what? If the WAR is automatically expanded do the new files take effect immediately I'm not sure about TC version 3 (I use 4.1 and 5.0), but on my server, the WAR file is placed into the appropriate place and put live as soon as it's deployed. I've found in my environment, that I have to be careful not to deploy when there are active sessions because my application doesn't handle the refresh gracefully. or do I need to restart tomcat still. Does the context in the server.xml need reloadable=true set for a WAR file expansion to take effect immediately? With WAR files, you don't touch server.xml any more. All of your web application specific configuration parameters are placed into context.xml in a folder called META-INF within the WAR. The server parses this file to determine how to deploy your application, what resources it needs, logging, etc. Nicely self contained. Thanks for the info..connected some dots for me. New Question (While I've got ya :): Given that I can use a WAR file to deploy, would you advise using Tomcat 5.x as my test server, creating a WAR and then deploying that to a production 3.3.1 server? I gotta agree with QM on this one... Test with the version that is in production. Is it possible for you folks to atleast migrate up to TC 4.1.xx in production? Your closer to current that way and migrating to 5.xx might be easier once you feel comfortable with TC 5. This would kinda let me test using 5.x and still support a 3.3.1 box. The app is very self-contained, except for a load of jar's in the lib. Thanks for you time!! JW Bob - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reloading JSP files without reloading classes/beans
Just an FYI for anybody else that is trying to learn the standard way of doing things in Tomcat development. The following article is out of date with respect to the most recent version of Tomcat, but it does provide a framework for doing JSP development using Tomcat. It also provides code/scripts that create WAR's and deploys them for you. http://jakarta.apache.org/tomcat/tomcat-3.2-doc/appdev/contents.html --JW QM wrote: On Mon, Oct 11, 2004 at 05:27:05PM -0500, Jonathan Wilson wrote: : New Question (While I've got ya :): Given that I can use a WAR file : to deploy, would you advise using Tomcat 5.x as my test server, : creating a WAR and then deploying that to a production 3.3.1 server? : This would kinda let me test using 5.x and still support a 3.3.1 box. Not really. To run an app under Tomcat 5, you should build against the Tomcat 5 JARs and such, which would limit the chances of that same WAR file working transparently under Tomcat 3. Not to mention, you really want your dev and production environments to mirror one another. Otherwise, how can you be certain the app will act the same in the two environments? To experiment with Tomcat 5, setup a separate instance and rebuild your app there. You can run both Tomcat versions on the same machine, if you play your cards right. For your other questions (e.g. how to create a WAR file, how to deploy), you may want to review the servlet spec and the Tomcat docs. -QM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
reloading JSP files without reloading classes/beans
Hello, I'm running 3.3.1 (and yes, I'll be upgrading to 5.x in the next few weeks as time allows) and want to reload JSP files, but not any class files. The root of the problem is that during beta testing I'm making lots of changes quickly(to JSP and classes/beans), but my system is in use. Everytime I recompile a classes/beans class it forces everyone to re-login to my system(context reloadable=true). Now, if I set reloadable to false the JSP files won't get recompiled...and I have to restart tomcat to effect the changes...no savings. Any ideas? Thanks and Regards, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Ideas on deploying a web-app piece-meal
I need some advice/HOW-TO's on developing and then deploying web-apps to a production server. I've yet to find anything comprehensive and that details the pros/cons of each method. Ideas/links? Thanks, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reloading JSP files without reloading classes/beans
Bob, You just answered my follow up to your previous email :) Hmm, so I run a concurrent version of my production app(being careful not to impact the databases) either on a different instance of Tomcat or just a different context within the same instance of Tomcat. Then when I'm ready I package up the source code into a WAR(what tool do I use for that? - must do research), copy it into the production servers webapps directory(and hopefully have all the configuration set properly to auto-expand) and then what? If the WAR is automatically expanded do the new files take effect immediately or do I need to restart tomcat still. Does the context in the server.xml need reloadable=true set for a WAR file expansion to take effect immediately? Thanks for the info..connected some dots for me. New Question (While I've got ya :): Given that I can use a WAR file to deploy, would you advise using Tomcat 5.x as my test server, creating a WAR and then deploying that to a production 3.3.1 server? This would kinda let me test using 5.x and still support a 3.3.1 box. The app is very self-contained, except for a load of jar's in the lib. Thanks for you time!! JW Robert Bateman wrote: The best advice I can give you is to investigate running your test application in a different context on the server. That way, you can recompile / alter the JSP files and everything else to your hearts content. IF that isn't possible, Tomcat runs quite nicely on my development machine where I can make changes without affecting anyone else. Bob On Mon, 2004-10-11 at 16:51, Jonathan Wilson wrote: Hello, I'm running 3.3.1 (and yes, I'll be upgrading to 5.x in the next few weeks as time allows) and want to reload JSP files, but not any class files. The root of the problem is that during beta testing I'm making lots of changes quickly(to JSP and classes/beans), but my system is in use. Everytime I recompile a classes/beans class it forces everyone to re-login to my system(context reloadable=true). Now, if I set reloadable to false the JSP files won't get recompiled...and I have to restart tomcat to effect the changes...no savings. Any ideas? Thanks and Regards, JW - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]