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 !










share|improve this question
























  • 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















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 !










share|improve this question
























  • 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













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 !










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$