?
Solved

Quartz  - as part of Web App...

Posted on 2009-04-29
4
Medium Priority
?
412 Views
Last Modified: 2013-11-24
Hi Experts,
I'm trying to implement Quartz with Birt in the exsisting web app. Birt part is working. Now i need to implement Quartz. Installed all the jars, created quartz.properties file. Got the StartSchedulerAction.java which does not do anythign right now except starting the scheduler. How do I proceed? I know i need to pass all the params to quarts from the JSP for it to load it into the jobs.xml and JobDataMap somehow. I know I need to create a class that implements Job, not sure what goes in there and how to create jobs.xml.  Any help would be really appreciated. Also, in the attached code not sure if i'm setting up the QUARTZ_FACTORY_KEY correctly.
Thank you.
public class StartSchedulerAction extends Action {
	public static final String QuartzFactoryServlet = null;
	StdSchedulerFactory factory;
 
	public ActionForward executeLogic(ActionMapping mapping, ActionForm form,
				HttpServletRequest request, HttpServletResponse response,
				UserSession userSession) throws Exception {
 
		// Retrieve the ServletContext
		ServletContext ctx = request.getSession().getServletContext();
		ctx.setAttribute("QUARTZ_FACTORY_KEY", factory);
 
		// Retrieve the factory from the ServletContext
		StdSchedulerFactory factory = ((StdSchedulerFactory)ctx.getAttribute("QUARTZ_FACTORY_KEY"));
 
 
 
		// Retrieve the scheduler from the factory
		Scheduler scheduler = factory.getScheduler();
 
		// Start the scheduler
		scheduler.start();
		// Forward to success page
		return mapping.findForward(Constants.SUCCESS);
	}
}

Open in new window

0
Comment
Question by:mmmanunya
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24267850
>                 ctx.setAttribute("QUARTZ_FACTORY_KEY", factory);

get rid of that line

Where is your factory getting created?

0
 

Author Comment

by:mmmanunya
ID: 24271992
THis is how it was but this line was complaining
StdSchedulerFactory factory = (StdSchedulerFactory)ctx.getAttribute(QuartzFactoryServlet.QUARTZ_FACTORY_KEY);

that QuartzFactoryServlet cannot be resolved.

This is what i have in web.xml, do I need to add something or add something in the code?
<servlet>
            <servlet-name>QuartzServlet</servlet-name>
            <servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
            <init-param>
                <param-name>config-file</param-name>
                <param-value>/quartz.properties</param-value>
            </init-param>
            <init-param>
                <param-name>shutdown-on-unload</param-name>
                <param-value>true</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
      </servlet>

public class StartSchedulerAction extends Action {
      public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {

            // Retrieve the ServletContext
            ServletContext ctx =
                   request.getSession().getServletContext();

            // Retrieve the factory from the ServletContext
            StdSchedulerFactory factory =
(StdSchedulerFactory)
ctx.getAttribute(
QuartzFactoryServlet.QUARTZ_FACTORY_KEY);

            // Retrieve the scheduler from the factory
            Scheduler scheduler = factory.getScheduler();

            // Start the scheduler
            scheduler.start();


            // Forward to success page
            return mapping.findForward(WebConstants.SUCCESS);
      }
}
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 24275019
StdSchedulerFactory factory = (StdSchedulerFactory)ctx.getAttribute(org.quartz.ee.servlet.QuartzInitializerServlet.QUARTZ_FACTORY_KEY);

0
 

Author Closing Comment

by:mmmanunya
ID: 31576107
It worked, Thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question