QuartzSchedulingException when setting a timer for a saga

1,831 views
Skip to first unread message

Prashant Tiwari

unread,
Nov 8, 2013, 10:06:46 AM11/8/13
to axonfr...@googlegroups.com
Hi,

I am trying to store the scheduled events of a saga in oracle 11g database using jpaSagaRepository. 
I am using axon 2.0.5 with quartz 2.1.7

I tried adding transactional annotation on the saga but still getting below exception

Error occured while scheduling job. org.quartz.JobPersistenceException: Couldn't determine job existence (AxonFramework-Events.event-eba15a6c-dd10-4ea4-a528-798733c98b25): ORA-00904: "SCHED_NAME": invalid identifier
 [See nested exception: java.sql.SQLSyntaxErrorException: ORA-00904: "SCHED_NAME": invalid identifier
]
org.axonframework.eventhandling.scheduling.SchedulingException: An error occurred while setting a timer for a saga
at org.axonframework.eventhandling.scheduling.quartz.QuartzEventScheduler.schedule(QuartzEventScheduler.java:73)
at org.axonframework.eventhandling.scheduling.quartz.QuartzEventScheduler.schedule(QuartzEventScheduler.java:118)
at com.sprint.vsb.em.saga.ROConversationSaga.startConversation(ROConversationSaga.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.axonframework.common.annotation.MethodMessageHandler.invoke(MethodMessageHandler.java:75)
at org.axonframework.common.annotation.MessageHandlerInvoker.invokeHandlerMethod(MessageHandlerInvoker.java:66)
at org.axonframework.saga.annotation.SagaEventHandlerInvoker.invokeSagaEventHandlerMethod(SagaEventHandlerInvoker.java:66)
at org.axonframework.saga.annotation.AbstractAnnotatedSaga.doHandle(AbstractAnnotatedSaga.java:84)
at org.axonframework.saga.annotation.AbstractAnnotatedSaga.handle(AbstractAnnotatedSaga.java:79)
at org.axonframework.saga.AbstractSagaManager.doInvokeSaga(AbstractSagaManager.java:190)
at org.axonframework.saga.AbstractSagaManager.startNewSaga(AbstractSagaManager.java:114)
at org.axonframework.saga.AbstractSagaManager.handle(AbstractSagaManager.java:79)
at org.axonframework.eventhandling.SimpleCluster.publish(SimpleCluster.java:44)
at org.axonframework.eventhandling.ClusteringEventBus$SimpleEventBusTerminal.publish(ClusteringEventBus.java:129)

Any pointers are welcome.

Cheers
Prashant Tiwari

Seamus Venasse

unread,
Nov 8, 2013, 12:46:08 PM11/8/13
to axonfr...@googlegroups.com
It appears that you haven't executed the Quartz DB script.  You will find the script for Oracle in the Quartz distribution under docs/dbTables/tables_oracle.sql.

Allard Buijze

unread,
Nov 8, 2013, 11:06:58 AM11/8/13
to axonfr...@googlegroups.com
Hi,

the problem doesn't seem transaction (nor Axon) related. It looks like the tables aren't properly created (either not at all or using the wrong scripts). For Quartz, you need to create the tables using the db scripts for you database type, which you can find in the quartz download. 

Cheers,

Allard
--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Prashant Tiwari

unread,
Nov 9, 2013, 7:44:13 AM11/9/13
to axonfr...@googlegroups.com
Hi Allard/Seamus,

Thanks for your reply. The problem was with the tables (wrong script) :(. 

Now I am facing another issue, when the scheduled saga event is triggered  i send a command to perform some task when it is finished & tries to commit i am getting following exception:

javax.persistence.TransactionRequiredException: no transaction is in progress 

in NestableUnitOfWork's performInnerCommit() method.

This behavior is strange as when other scheduled saga events are fired i am getting no such exception.

I have added the transaction manager in the command bus. Is there any place i missed providing the transactionManager?

Cheers,
Prashant Tiwari


 




--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/IlWZ0UHK2hk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframewor...@googlegroups.com.

Prashant Tiwari

unread,
Nov 9, 2013, 8:11:23 AM11/9/13
to axonfr...@googlegroups.com
Update: I am getting this exception when committing the unit of work associated with the first command in saga too

bui...@gmail.com

unread,
Nov 9, 2013, 8:23:19 AM11/9/13
to axonfr...@googlegroups.com
Hi,

did you configure a transaction manager on the EventScheduler as well?

Cheers,

Allard

Prashant Tiwari

unread,
Nov 10, 2013, 12:58:56 AM11/10/13
to axonfr...@googlegroups.com
Hi Allard,

Yes i configured a transaction manager on event scheduler.

Allard Buijze

unread,
Nov 10, 2013, 9:41:55 AM11/10/13
to axonfr...@googlegroups.com
Strange. I guess gou best option is to do some debugging and find out why there is no transaction bound to the unit of work. 
Make sure that every mechanism that starts a process must be configured with a TransactionManager. Think of AsyncSagaManager, EventPublishers, command bus, async event bus, etc. 

Cheers,

Allard

Prashant Tiwari

unread,
Nov 11, 2013, 1:51:58 AM11/11/13
to axonfr...@googlegroups.com
Update: Following is the stacktrace when quartz fires the scheduled event job

javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:301)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
at com.sun.proxy.$Proxy24.flush(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at com.sun.proxy.$Proxy24.flush(Unknown Source)
at org.axonframework.saga.repository.jpa.JpaSagaRepository.updateSaga(JpaSagaRepository.java:171)
at org.axonframework.saga.repository.AbstractSagaRepository.commit(AbstractSagaRepository.java:69)
at org.axonframework.saga.AbstractSagaManager.commit(AbstractSagaManager.java:209)
at org.axonframework.saga.AbstractSagaManager.loadAndInvoke(AbstractSagaManager.java:183)
at org.axonframework.saga.AbstractSagaManager.invokeExistingSagas(AbstractSagaManager.java:94)
at org.axonframework.saga.AbstractSagaManager.handle(AbstractSagaManager.java:75)
at org.axonframework.eventhandling.SimpleCluster.publish(SimpleCluster.java:44)
at org.axonframework.eventhandling.ClusteringEventBus$SimpleEventBusTerminal.publish(ClusteringEventBus.java:129)
at org.axonframework.eventhandling.ClusteringEventBus.publish(ClusteringEventBus.java:91)
at org.axonframework.unitofwork.DefaultUnitOfWork.publishEvents(DefaultUnitOfWork.java:256)
at org.axonframework.unitofwork.DefaultUnitOfWork.doCommit(DefaultUnitOfWork.java:139)
at org.axonframework.unitofwork.NestableUnitOfWork.performInnerCommit(NestableUnitOfWork.java:196)
at org.axonframework.unitofwork.NestableUnitOfWork.commitInnerUnitOfWork(NestableUnitOfWork.java:226)
at org.axonframework.unitofwork.DefaultUnitOfWork.doCommit(DefaultUnitOfWork.java:140)
at org.axonframework.unitofwork.NestableUnitOfWork.commit(NestableUnitOfWork.java:53)
at org.axonframework.eventhandling.scheduling.quartz.FireEventJob.execute(FireEventJob.java:69)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)

Cheers,
Prashant

Allard Buijze

unread,
Nov 11, 2013, 3:27:17 AM11/11/13
to Axon Framework Users
Hi Prashant,

can you send your QuartzEventScheduler configuration? To me, it looks like there is no transaction manager configured on it.

Cheers,

Allard

Prashant Tiwari

unread,
Nov 11, 2013, 8:00:24 AM11/11/13
to axonfr...@googlegroups.com
Hi Allard,

The issue was the transactionManager was not set in org.axonframework.eventhandling.scheduling.quartz.QuartzEventSchedulerFactoryBean. I had provided the 'transactionManager' in org.springframework.scheduling.quartz.SchedulerFactoryBean & was thinking that QuartzEventSchedulerFactoryBean will pick it from SchedulerFactoryBean. 

Few updates from my side:

1) When i tried with inMemorySagaRepository i am getting no such exception.
2) Also, i tried with asyncSagaManager & application worked properly.

My question is when i use <axon:asyn/> tag inside <axon:saga-manager />  and do i need to extend my Saga class from "AsyncAnnotatedSagaManager" instead of "AbstractAnnotatedSaga" or 
"AsyncAnnotatedSagaManager" gets called automatically?


Cheers,
Prashant Tiwari

Allard Buijze

unread,
Nov 11, 2013, 10:38:36 AM11/11/13
to Axon Framework Users
Hi Prashant,

saga's should never extends AsyncAnnotatedSagaManager. Always extend from AsyncAnnotatedSaga (note the suffic SagaManager on the first one). The fact that processing is done asynchronous is not of importance to the Saga itself.

Adding the <axon:async/> to your configuration will automatically cause the SagaManager instance to be an AsyncAnnotatedSagaManager.

Cheers,

Allard
Reply all
Reply to author
Forward
0 new messages