<p>My employer just asked me to run a timed batch process in a Java EE WebSphere application they have running. It's supposed to run a certain class at 11:30 pm everyday.</p>

<p>I'm not very familiar with Java EE nor WebSphere server (or tomcat, in the development environment), and I've been digging around but all I've found is about the java timer class but not how to set it or invoke it.</p>

<p>It seems that editing the web.xml file is required as well.</p>

<p>Any help will be appreciated!</p>

[{'answer_id': 78227, 'author': 'Cheekysoft', 'author_id': 1820, 'author_profile': 'https://Stackoverflow.com/users/1820', 'pm_score': 4, 'selected': True, 'text': '<p>You should look at the open-source <a href="http://www.quartz-scheduler.org/" rel="noreferrer">Quartz library</a> from OpenSymphony. Very easy to use and perfect for this kind of thing.</p>\n\n<p>TimerTasks are best suited for running something in a short time in the future. But for a repeated execution in a large timeframe such as this, Quartz excels. You can even keep your list of upcoming tasks in persistent storage such as a file or database, so upcoming timed jobs are not lost if your application is restarted.</p>\n\n<p>Also, there\'s a fantastic abstraction for Quartz in the Spring framework.</p>\n'}, {'answer_id': 78241, 'author': 'user13276', 'author_id': 13276, 'author_profile': 'https://Stackoverflow.com/users/13276', 'pm_score': 0, 'selected': False, 'text': "<p>In your web.xml you can configure a servlet to load at startup.<br>\nSyntax:</p>\n\n<p>&lt;servlet servlet-name='hello'\n         servlet-class='test.HelloWorld'&gt;<br>\n  &lt;load-on-startup/&gt;<br>\n&lt;/servlet&gt;</p>\n\n<p>Do this, then in the init method in the servlet you can set up a Timer / TimerTask to do whatever it is you need to do.  TimerTasks are like Threads except you can schedule them when to run.</p>\n"}, {'answer_id': 79243, 'author': 'feniix', 'author_id': 14664, 'author_profile': 'https://Stackoverflow.com/users/14664', 'pm_score': 0, 'selected': False, 'text': '<p>Quartz is part of the standard JBoss 4.2.x distribution.</p>\n\n<p>And is a really good library, that without much work you can also define simple workflows.</p>\n'}, {'answer_id': 96446, 'author': 'boes', 'author_id': 17746, 'author_profile': 'https://Stackoverflow.com/users/17746', 'pm_score': 0, 'selected': False, 'text': '<p>There is no support for scheduling in WebSphere.</p>\n\n<p>If you are on unix you can use crontab to schedule a request to a page of your websphere application. I suppose on windows there is also a possibility to schedule a request to a page. In my crontab I schedule a request to a webpage each day at 8:45</p>\n\n<p>45 8 * * * GET <a href="http://www.domain.com/myBatch?securitykey=verysecret" rel="nofollow noreferrer">http://www.domain.com/myBatch?securitykey=verysecret</a></p>\n\n<p>Now every morning the myBatch servlet is called and there I can do whatever needs to be done at that time. To avoid others calling this page and start the batch, I added the securitykey parameter. </p>\n'}, {'answer_id': 96584, 'author': 'Martin Klinke', 'author_id': 1793, 'author_profile': 'https://Stackoverflow.com/users/1793', 'pm_score': 1, 'selected': False, 'text': '<p>EJB 3.1 will have improved timer services, as well as application lifecycle hooks that remove the need to use servlets to start tasks without user interaction.</p>\n\n<p>This may answer the question title, but for the "real" question concerning a legacy application (written more than 6 months ago ;)) running on websphere I\'d recommend to go with the start-up servlet and the EJB timer service. </p>\n\n<p><a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Session5.html" rel="nofollow noreferrer">Timer Service in J2EE 1.4 (EJB 2.1)</a></p>\n\n<p>For EJB 3.0 (and 3.1 as soon as available), there are some nice annotations ;)</p>\n\n<p>I\'d not introduce another <a href="http://www.quartz-scheduler.org/" rel="nofollow noreferrer">library</a> unless you REALLY need it. The timer service should suffice for performing an arbitrary job on a daily basis.</p>\n\n<p>HTH,<br>\nMartin</p>\n'}, {'answer_id': 313512, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>In WebSphere, you can use the Scheduler Service to trigger the execution of a method in a java class. \nThe scheduler provides a calendar for scheduling the execution of jobs (similar to cron) or you could develop your own.</p>\n\n<p>Here\'s a link to the page describing the scheduler in the WAS 6.1 documentation:</p>\n\n<p><a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp</a></p>\n'}, {'answer_id': 966360, 'author': 'Everett Toews', 'author_id': 25991, 'author_profile': 'https://Stackoverflow.com/users/25991', 'pm_score': 0, 'selected': False, 'text': '<p>There is support for scheduling included in WebSphere.</p>\n\n<p>WAS v7.0\n<a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.base.doc/info/aes/ae/welc6tech_sch.html" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/topic/com.ibm.websphere.base.doc/info/aes/ae/welc6tech_sch.html</a></p>\n\n<p>WAS v6.1\n<a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/welc6tech_sch.html" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/topic/com.ibm.websphere.base.doc/info/aes/ae/welc6tech_sch.html</a></p>\n'}]
['https://Stackoverflow.com/questions/78194', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14284/']