java


How to catch any uncaught exception in a spring application? [duplicate]


How to customize the exception handling for "#Scheduled" annotation from spring ?
I have cron jobs which will be triggered in the server (Tomcat 6) and when any exceptions occur I need to do some handling.
Spring version 3.2
Tomcat Server 6
You could implement and register an ErrorHandler for the ThreadPoolTaskScheduler that is used for your scheduling annotations.
<task:annotation-driven scheduler="yourThreadPoolTaskScheduler" />
<bean id="yourThreadPoolTaskScheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler">
<property name="poolSize" value="5" />
<property name="errorHandler" ref="yourScheduledTaskErrorHandler" />
</bean>
<bean id="yourScheduledTaskErrorHandler"
class="com.example.YourScheduledTaskErrorHandler"/>
Why not wrap your business logic and do a simple try catch in your #schedule method. Then you can log or take whatever action is necessary for failure cases.
#Scheduled(cron = "${schedulerRate}")
public void scheduledJob() {
try {
businessLogicService.doBusinessLogic();
} catch (Exception e) {
log.error(e);
}
}

Related Links

versions in Javers query language
Java - Converting String into instance of interface
How to validate string using java
Java connectivity to database
Insert object in Elements - Jsoup Java [duplicate]
/bin/bash: /bin/java: No such file or directory
Properties parseFabricURL returning null
How to make reasonable assumptions about stack works
How to check if a string is date?
How to use exists and $p in Drools?
callback nullpointer exception [duplicate]
JDBC query does not see session.flush modifications on the same transaction
Java : space makes a difference in compilation?
Why java may throw OutOfMemoryError when it has a lot memory left?
Java Web Start error: Missing “Permissions” in manifest… but it's there
how can i write in particular location of a text file in java

Categories

HOME
rsyslog
rsync
yahoo-oauth
youtube-api-v3
fsm
serverspec
fancybox
awesome-wm
maude-system
metatrader4
modelica
correlation
google-cloud-spanner
dtrace
msp430
shared-hosting
visjs
intentfilter
sylius
mmap
captiveportal
crystal-reports-2010
chromebook
phpfox
filezilla
spring-mybatis
facebook-apps
windows-server-2000
phonegap
ioio
siesta-swift
karaf
noraui
suricata
git-merge
scaffold
space-complexity
mixture-model
mesos-chronos
elmah
google-closure
nomethoderror
checkboxlist
acoustics
reactive-cocoa-5
fault
youcompleteme
qsslsocket
theming
promela
worksheet
pebble-watch
tropo
elgg
imanage
or-tools
background-service
intrusion-detection
underscore.js-templating
mikroc
google-web-starter-kit
captivenetwork
php-parse-error
system.management
phpcas
hsv
unity-networking
rtbkit
execute
marching-cubes
metaclass
feedback
angular-leaflet-directive
sailfish-os
cisco-ios
apache-commons-net
sorl-thumbnail
jsonpickle
camanjs
coldbox
angularjs-ng-click
heisenbug
wp-query
system.net.webexception
hyprlinkr
algebraic-data-types
dbconnection
back-stack
http-unit
free-variable
itmstransporter
dmoz
venn-diagram
work-stealing
subgurim-maps
psi
invite
appender
calling-convention
jmock
xfbml
h.323
firefox-5

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App