Announcement Announcement Module
Collapse
No announcement yet.
@AfterThrowing and String Literal... Error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @AfterThrowing and String Literal... Error

    I have no idea why I am having this error. I am getting "String literal is not properly closed by a double-quote" on the AfterThrowing annotation(see the attached image).

    Code:
    @AfterThrowing(pointcut="FileOperationLogging()",throwing="e")    
    public void logAfterThrowing(JoinPoint joinPoint, NullPointerException e){
            
        log.error("NullPointerException in " + joinPoint.getSignature().getName() + "()");
    }
    Thanks,

  • #2
    You can't declare a JoinPoint object as input of a method decorated with @AfterThrowing. Only declare the exception as input.
    If you need reflection information (for tracing purposes or whatever) you should use an @Around advice, which gives you the ProceedingJoinPoint object.

    Comment


    • #3
      Thanks for your reply.. I did according to the Spring Recipes 2e where the joinpoint is passed as parameter to the method annotated by afterthrowing. I guess I will stick @Around however this string literal error doesn't seem normal to me.
      Last edited by acidrous; Sep 5th, 2011, 01:21 PM.

      Comment


      • #4
        After a more careful reading of the AOP chapter in the official Spring reference documentation, I agree with you. There is the possibility to pass a JoinPoint parameter as first attribute of an advice method.

        My guess is that they forgot to update the Eclipse plugin to recognize this feature which was introduced later. If you try to compile your project outside the ide, does it work? I'd give it a try...

        Comment


        • #5
          Yes, it works if you compile outside the ide. Probably the plugin doesn't recognize the feature yet. Thanks again

          Comment

          Working...
          X