Results 1 to 5 of 5

Thread: @AfterThrowing and String Literal... Error

  1. #1
    Join Date
    Aug 2011
    Location
    Montreal
    Posts
    3

    Default @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,
    Attached Images Attached Images

  2. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    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.

  3. #3
    Join Date
    Aug 2011
    Location
    Montreal
    Posts
    3

    Default

    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 at 01:21 PM.

  4. #4
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    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...

  5. #5
    Join Date
    Aug 2011
    Location
    Montreal
    Posts
    3

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •