[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2306) Can't create Quartz Cron job at startup

NSA (JIRA) jira-events at lists.jboss.org
Thu Mar 27 13:25:43 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBSEAM-2306?page=comments#action_12405195 ] 
            
NSA commented on JBSEAM-2306:
-----------------------------

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
	xmlns:core="http://jboss.com/products/seam/core"
	xmlns:drools="http://jboss.com/products/seam/drools"
	xmlns:mail="http://jboss.com/products/seam/mail"
	xmlns:persistence="http://jboss.com/products/seam/persistence"
	xmlns:security="http://jboss.com/products/seam/security"
	xmlns:transaction="http://jboss.com/products/seam/transaction"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:async="http://jboss.com/products/seam/async"
	xsi:schemaLocation=
	            "http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd
                 http://jboss.com/products/seam/async http://jboss.com/products/seam/async-2.0.xsd
                 http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
                 http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
                 http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
                 http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd 
                 http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
                 http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd">

	<core:init debug="@debug@" jndi-pattern="@jndiPattern@" />

	<core:manager concurrent-request-timeout="500"
		conversation-timeout="120000" conversation-id-parameter="cid" />

	<persistence:managed-persistence-context name="entityManager"
		auto-create="true"
		persistence-unit-jndi-name="java:/glacierEntityManagerFactory" />

	<drools:rule-base name="securityRules">
		<drools:rule-files>
			<value>/META-INF/security-rules.drl</value>
		</drools:rule-files>
	</drools:rule-base>

	<security:identity
		authenticate-method="#{authenticator.authenticate}"
		security-rules="#{securityRules}" />

	<event type="org.jboss.seam.notLoggedIn">
		<action execute="#{redirect.captureCurrentView}" />
	</event>
	<event type="org.jboss.seam.postAuthenticate">
		<action execute="#{redirect.returnToCapturedView}" />
	</event>

	<transaction:ejb-transaction />
	
	<async:quartz-dispatcher/>

</components>


> Can't create Quartz Cron job at startup
> ---------------------------------------
>
>                 Key: JBSEAM-2306
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2306
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: Async
>    Affects Versions: 2.0.0.GA
>         Environment: Windows, JBoss 4.2.1 GA
>            Reporter: NSA
>         Assigned To: Pete Muir
>             Fix For: 2.0.2.GA, 2.1.0.BETA1
>
>
> I've set up an ObserveInitilization class as suggested by Pete Muir here: http://in.relation.to/Bloggers/DoingSomethingAtStartupWithSeam
> It looks like this:
> @Name("observeInitialization")
> public class ObserveInitialization {
>    
>    @In(create=true) 
>    Updater updater;
>    @Observer("org.jboss.seam.postInitialization")
>    public void start() {
> 	   initialize(30 * 1000l);
>    }
>    
>    @Asynchronous
>    public void initialize(@Duration long durationInMilliseconds) {
> 	      updater.update(new Date(), "0 0/3 * * * ?");
>    }
> }
> The Updater class looks like this:
> @Name("updater")
> public class Updater {
> 	@In
> 	private EntityManager entityManager;
> 	@Logger
> 	private Log log;
> 	@Asynchronous
> 	public void update(@Expiration Date start, @IntervalCron String cron) {
>      //...
>      }
> }	
> The issue is this code calls ThreadPoolDispatcher.scheduleWithExecutorService, which casts the return value of createSchedule to a TimerSchedule.
> Because I'm using an @IntervalCron the return value of createSchedule is a CronSchedule which extends Schedule, but not TimerSchedule, so I get a ClassCastException:
> 09:14:59,387 ERROR [[/admin]] Exception sending context initialized event to listener instance of cl
> ass org.jboss.seam.servlet.SeamListener
> java.lang.ClassCastException: org.jboss.seam.async.CronSchedule
> 	at org.jboss.seam.async.ThreadPoolDispatcher.scheduleInvocation(ThreadPoolDispatcher.java:47)
> 	at org.jboss.seam.async.ThreadPoolDispatcher.scheduleInvocation(ThreadPoolDispatcher.java:29)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
> 	at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
> 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
> 	at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
> 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
> 	at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
> 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
> 	at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
> 	at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
> 	at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
> 	at org.jboss.seam.async.ThreadPoolDispatcher_$$_javassist_6.scheduleInvocation(ThreadPoolDispatcher
> _$$_javassist_6.java)
> 	at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:38)
> 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
> 	at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
> 	at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
> 	at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
> 	at com.company.Updater_$$_javassist_5.update(Updater_$$_javassist_5.java)
> 	at com.company.ObserveInitialization.initialize(ObserveInitialization.java:29)
> 	
> I compared this to the Quartz example packaged with Seam.
> That example also calls createSchedule but as a parameter to QuartzDispatcher.scheduleWithQuartzService which accepts a Schedule, thus no ClassCastException.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list