Using @AfterThrowing with @ExceptionHandler
up vote
2
down vote
favorite
package com.fourthlion.lapp.ccd.config;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class ExceptionAlerts {
public ExceptionAlerts() {
System.err.println("Class Scanned");
}
@AfterThrowing(pointcut = "com.name.papp.star", throwing = "ex")
public void doRecoveryAction(Throwable ex) throws Throwable {
System.err.println(">>>>>>>>>>>>>>>>Recovery Actions++++++++++++++++");
}
}
Service Interface
package com.name.papp.star.auth.service;
public interface SignInService {
CustomerSignInDTO signIn()
throws LappException;
}
//Service Implementation Class
package com.name.papp.star.auth.service.impl;
public class SignInServiceImpl implements SignInService {
@Override
@Transactional(readOnly = false, rollbackFor = Exception.class)
public CustomerSignInDTO signInCustomer(CustomerDeviceDTO
customerDeviceDTO, String mobileNumber,
boolean createIfNotExist) throws LappException {
// Throwing Exception Here
}
}
Problem -
Spring-Boot-1.2.5
Method doRecoveryActions never gets called. I am also using @ExceptionHandler somehwere to prepare the error response. Is it because @ExceptionHandler catches all the exception and doRecoveryActions is never called ? Any Suggestions would be appreciated !
java spring-aop
add a comment |
up vote
2
down vote
favorite
package com.fourthlion.lapp.ccd.config;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class ExceptionAlerts {
public ExceptionAlerts() {
System.err.println("Class Scanned");
}
@AfterThrowing(pointcut = "com.name.papp.star", throwing = "ex")
public void doRecoveryAction(Throwable ex) throws Throwable {
System.err.println(">>>>>>>>>>>>>>>>Recovery Actions++++++++++++++++");
}
}
Service Interface
package com.name.papp.star.auth.service;
public interface SignInService {
CustomerSignInDTO signIn()
throws LappException;
}
//Service Implementation Class
package com.name.papp.star.auth.service.impl;
public class SignInServiceImpl implements SignInService {
@Override
@Transactional(readOnly = false, rollbackFor = Exception.class)
public CustomerSignInDTO signInCustomer(CustomerDeviceDTO
customerDeviceDTO, String mobileNumber,
boolean createIfNotExist) throws LappException {
// Throwing Exception Here
}
}
Problem -
Spring-Boot-1.2.5
Method doRecoveryActions never gets called. I am also using @ExceptionHandler somehwere to prepare the error response. Is it because @ExceptionHandler catches all the exception and doRecoveryActions is never called ? Any Suggestions would be appreciated !
java spring-aop
Does it work if you change signature to doRecoveryAction(Throwable ex)?
– Ermintar
yesterday
No it doesn't. Tried that as well.
– kashish verma
yesterday
Pls, post the real pointcut & executed method signature. @ExceptionHandler doesn't spoil AOP handlers
– Ermintar
yesterday
Trouble is with your pointcut expression. Try pointcut = "execution(* com.name.papp.star.*)" to scan full package or "execution(* com.name.papp.star.auth.service.impl.signInCustomer(..))" for exact method
– Ermintar
yesterday
Around("execution(* com..*ServiceImpl.*(..))") works perfectly with Around , but gives error when I use AfterThrowing. Could you please suggest an alternate, I have to give package based restrictions.
– kashish verma
yesterday
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
package com.fourthlion.lapp.ccd.config;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class ExceptionAlerts {
public ExceptionAlerts() {
System.err.println("Class Scanned");
}
@AfterThrowing(pointcut = "com.name.papp.star", throwing = "ex")
public void doRecoveryAction(Throwable ex) throws Throwable {
System.err.println(">>>>>>>>>>>>>>>>Recovery Actions++++++++++++++++");
}
}
Service Interface
package com.name.papp.star.auth.service;
public interface SignInService {
CustomerSignInDTO signIn()
throws LappException;
}
//Service Implementation Class
package com.name.papp.star.auth.service.impl;
public class SignInServiceImpl implements SignInService {
@Override
@Transactional(readOnly = false, rollbackFor = Exception.class)
public CustomerSignInDTO signInCustomer(CustomerDeviceDTO
customerDeviceDTO, String mobileNumber,
boolean createIfNotExist) throws LappException {
// Throwing Exception Here
}
}
Problem -
Spring-Boot-1.2.5
Method doRecoveryActions never gets called. I am also using @ExceptionHandler somehwere to prepare the error response. Is it because @ExceptionHandler catches all the exception and doRecoveryActions is never called ? Any Suggestions would be appreciated !
java spring-aop
package com.fourthlion.lapp.ccd.config;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class ExceptionAlerts {
public ExceptionAlerts() {
System.err.println("Class Scanned");
}
@AfterThrowing(pointcut = "com.name.papp.star", throwing = "ex")
public void doRecoveryAction(Throwable ex) throws Throwable {
System.err.println(">>>>>>>>>>>>>>>>Recovery Actions++++++++++++++++");
}
}
Service Interface
package com.name.papp.star.auth.service;
public interface SignInService {
CustomerSignInDTO signIn()
throws LappException;
}
//Service Implementation Class
package com.name.papp.star.auth.service.impl;
public class SignInServiceImpl implements SignInService {
@Override
@Transactional(readOnly = false, rollbackFor = Exception.class)
public CustomerSignInDTO signInCustomer(CustomerDeviceDTO
customerDeviceDTO, String mobileNumber,
boolean createIfNotExist) throws LappException {
// Throwing Exception Here
}
}
Problem -
Spring-Boot-1.2.5
Method doRecoveryActions never gets called. I am also using @ExceptionHandler somehwere to prepare the error response. Is it because @ExceptionHandler catches all the exception and doRecoveryActions is never called ? Any Suggestions would be appreciated !
java spring-aop
java spring-aop
edited yesterday
asked yesterday
kashish verma
614
614
Does it work if you change signature to doRecoveryAction(Throwable ex)?
– Ermintar
yesterday
No it doesn't. Tried that as well.
– kashish verma
yesterday
Pls, post the real pointcut & executed method signature. @ExceptionHandler doesn't spoil AOP handlers
– Ermintar
yesterday
Trouble is with your pointcut expression. Try pointcut = "execution(* com.name.papp.star.*)" to scan full package or "execution(* com.name.papp.star.auth.service.impl.signInCustomer(..))" for exact method
– Ermintar
yesterday
Around("execution(* com..*ServiceImpl.*(..))") works perfectly with Around , but gives error when I use AfterThrowing. Could you please suggest an alternate, I have to give package based restrictions.
– kashish verma
yesterday
add a comment |
Does it work if you change signature to doRecoveryAction(Throwable ex)?
– Ermintar
yesterday
No it doesn't. Tried that as well.
– kashish verma
yesterday
Pls, post the real pointcut & executed method signature. @ExceptionHandler doesn't spoil AOP handlers
– Ermintar
yesterday
Trouble is with your pointcut expression. Try pointcut = "execution(* com.name.papp.star.*)" to scan full package or "execution(* com.name.papp.star.auth.service.impl.signInCustomer(..))" for exact method
– Ermintar
yesterday
Around("execution(* com..*ServiceImpl.*(..))") works perfectly with Around , but gives error when I use AfterThrowing. Could you please suggest an alternate, I have to give package based restrictions.
– kashish verma
yesterday
Does it work if you change signature to doRecoveryAction(Throwable ex)?
– Ermintar
yesterday
Does it work if you change signature to doRecoveryAction(Throwable ex)?
– Ermintar
yesterday
No it doesn't. Tried that as well.
– kashish verma
yesterday
No it doesn't. Tried that as well.
– kashish verma
yesterday
Pls, post the real pointcut & executed method signature. @ExceptionHandler doesn't spoil AOP handlers
– Ermintar
yesterday
Pls, post the real pointcut & executed method signature. @ExceptionHandler doesn't spoil AOP handlers
– Ermintar
yesterday
Trouble is with your pointcut expression. Try pointcut = "execution(* com.name.papp.star.*)" to scan full package or "execution(* com.name.papp.star.auth.service.impl.signInCustomer(..))" for exact method
– Ermintar
yesterday
Trouble is with your pointcut expression. Try pointcut = "execution(* com.name.papp.star.*)" to scan full package or "execution(* com.name.papp.star.auth.service.impl.signInCustomer(..))" for exact method
– Ermintar
yesterday
Around("execution(* com..*ServiceImpl.*(..))") works perfectly with Around , but gives error when I use AfterThrowing. Could you please suggest an alternate, I have to give package based restrictions.
– kashish verma
yesterday
Around("execution(* com..*ServiceImpl.*(..))") works perfectly with Around , but gives error when I use AfterThrowing. Could you please suggest an alternate, I have to give package based restrictions.
– kashish verma
yesterday
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371744%2fusing-afterthrowing-with-exceptionhandler%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does it work if you change signature to doRecoveryAction(Throwable ex)?
– Ermintar
yesterday
No it doesn't. Tried that as well.
– kashish verma
yesterday
Pls, post the real pointcut & executed method signature. @ExceptionHandler doesn't spoil AOP handlers
– Ermintar
yesterday
Trouble is with your pointcut expression. Try pointcut = "execution(* com.name.papp.star.*)" to scan full package or "execution(* com.name.papp.star.auth.service.impl.signInCustomer(..))" for exact method
– Ermintar
yesterday
Around("execution(* com..*ServiceImpl.*(..))") works perfectly with Around , but gives error when I use AfterThrowing. Could you please suggest an alternate, I have to give package based restrictions.
– kashish verma
yesterday