Spring AOP を使用して、例外が発生した正確な行を取得しようとしています。
AspectLogger.java のコード:
@AfterThrowing(pointcut = "execution(* com.ing.trialbal.*.*.*(..))", throwing = "ex")
public void afterThrowingAdvice(JoinPoint jp, TrialBalException ex) {
logger.info("Exception : After throwing " + jp.getSignature().getName()
+ "()");
logger.info("********* " + ex.getMessage()
+ " Exception occured during " + jp.toShortString());
System.out.println("********* " + ex.getMessage()
+ " Exception occured during " + jp.toShortString());
}
Service に例外をスローしている DAO クラスのコード:
try {
...
} catch (Exception e) {
System.out.println("(((((((((((((" + e.getStackTrace().toString());
throw new TrialBalException("Error.TrialBalance.Exception : " + e);
} finally {
try {
pStmt.close();
} catch (Exception e) {
e.printStackTrace();
}
}
ログで私は取得しています:
例外: getLongTBDetail() をスローした後
Error.TrialBalance.Exception: java.lang.NullPointerException 実行中に例外が発生しました(LongTBDaoImpl.getLongTBDetail(..))
エラーが発生した正確な行番号を取得する方法がわかりません。助けてください。