Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeanCreationException: Error creating bean #1

Closed
maricn opened this issue Apr 2, 2015 · 6 comments
Closed

BeanCreationException: Error creating bean #1

maricn opened this issue Apr 2, 2015 · 6 comments

Comments

@maricn
Copy link

maricn commented Apr 2, 2015

Hi,

I'm having an issue with starting my service with automon. I'm not that into aspectj, so I hope you could give me a hint whether my setup is just wrong or something could be improved in automon project.
I get:

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'serviceApplicationConfiguration': 
BeanPostProcessor before instantiation of bean failed; nested exception is java.lang.IllegalStateException: 
Expecting to find 2 arguments to bind by name in advice, but actually found 1 arguments.

in

org.springframework.aop.aspectj.AbstractAspectJAdvice#calculateArgumentBindings

AbstractAspectJAdvice has only one String in argumentNames when trying to bind Object around() throws Throwable : _monitor() from AutomonAspect.aj. He recognizes only the first argument in runtime (_monitor).
I'm using spring 3.2.4.RELEASE (which I tested with your spring-woven example - works fine). Instead of using xml based bean definition, I use org.springframework.context.annotation.Beans and pointcuts and aspects.

My ServiceApplicationConfiguration which is annotated with org.springframework.context.annotation.Configuration and EnableAspectJAutoProxy(proxyTargetClass = true) should load my Aspect which extends your SpringBase and defines pointcuts same as you do in spring-woven example. If you have any idea what I'm doing wrong, I'd appreciate the hints.

Cheers,
Nikola

P.S. Perhaps it's unclear. I'd see to get some example in my fork with minimal code representing the issue soon.

@stevensouza
Copy link
Owner

I haven't had time to run all test cases with Automon yet.

My spring_woven project actually doesn't use spring to do the monitoring. It instead uses aspectj's Build-time weaving. I would like to work with you to get an example that uses the more traditional spring aop like you are trying to do. Please create a minimal spring project that duplicates the problem and I will look into it as the issue is not clear to me just from your message above.

@stevensouza
Copy link
Owner

"He recognizes only the first argument in runtime (_monitor)."
Not sure what you mean when you say 'he'.

Also, note that the spring_woven example uses aspectj's compiler and not javac. That is defined in the spring_woven pom.xml file. To see if you can get it to work try to copy the spring_woven project and modify it instead of creating a project from scratch.

@maricn
Copy link
Author

maricn commented Apr 3, 2015

Ah, now I see the comment in pom.xml of spring_woven module regarding this specific exception. I'll try to play around and see if anything useful comes out of it.

@stevensouza
Copy link
Owner

Also, you could also copy the whole code from SpringBase and make your own @around method. I think the problem may be that Spring uses a ProceedingJoinPoint and in my base class I use JoinPoint.StaticPart.

So if you try to rewrite the following using straight java and @AspectJ annotations that may fix the problem. It is mostly copying and pasting. Once we figure it out I can make any needed changes to Automon. Let me know if you need help. I am on travel right now, but I will have more time to focus on it in a few days.

    Object around() throws Throwable : _monitor()  {
        // Note: context is typically a Timer/Monitor object returned by the monitoring implementation (Jamon, JavaSimon, Metrics,...)
        // though to this advice it is simply an object and the advice doesn't care what the intent of the context/object is.
        Object context = openMon.start(thisJoinPointStaticPart);
        try {
            Object retVal = proceed();
            openMon.stop(context);
            return retVal;
        } catch (Throwable throwable) {
            openMon.stop(context, throwable);
            throw throwable;
        }
    }

@stevensouza
Copy link
Owner

stevensouza commented Jul 24, 2016

Sorry it took me so long to get around to this, but Automon now works with Spring (automon 1.0.2). I am posting this just in case someone else looks on this thread to see if it was resolved.

Here is an example maven module using spring: https://github.com/stevensouza/automon/tree/master/spring_aop

Here is how you would define it in your application context file: https://github.com/stevensouza/automon/blob/master/spring_aop/src/main/resources/applicationContext.xml

Cheers,
Steve

@stevensouza
Copy link
Owner

Resolved and now works with spring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants