Using AOP for non services

Even if you did it in a throw away module, it would be good enough for us to take a look at your exact changes, and possibly even try them out.

1 Like

@dkayiwa he hasn’t yet resolved the issue so there is nothing to update on the wiki, he was saying the error went away that he was running into but he hasn’t yet got the functionality to work.

sorry guys: @dkayiwa, @wyclif, i have been on and off these 2 days, you may have a look at my configurations for aspectj, otherwise it leads to the exact error above. i think its deceptive somehow. So many unanswered related posts i have found on the web and others that had some suggestions were failing. anyways here is the basic commit

@k.joseph what is the issue right now? Are you getting an exception or you’re saying your advice isn’t getting invoked, if it’s not getting called it must because of the pointcut expression, can you try changing it to execution(* authenticate(..)) and see if that works.

Looks to me like the test or project is incorrectly setup and has nothing to do with the AOP stuff, org/openmrs/module/appframework/factory/UserAppFactory.class is a class in the appframework module, what is that doing on the classpath in your unit test, it should only exist at runtime anyways.

the problem is whether with or without the advice, just adding <aop:aspectj-autoproxy/> fails into https://gist.github.com/kaweesi/33ed2d87040456a865cecf4381b9036e

i use org.openmrs.module.appframework.service.AppFrameworkService in my activator to manage apps

Then that’s the problem, there is missing dependencies hence the class loading issues, that’s why I did say the error message is a little deceptive.

Still confused though, which activator? This activator does nothing and I don’t see the appframework dependency in your pom files, I think you need to clean up your test or project to resolve dependency issues, otherwise your AOP config isn’t the issue for now.

https://github.com/jembi/openmrs-module-msfcore/blob/MOO-14-registration-fix/api/src/main/java/org/openmrs/module/msfcore/MSFCoreActivator.java

use the MOO-14-registration-fix branch

Sorry, I didn’t realize you were working on a different branch, now I see the activator and dependency in the branch. Then you need to fix the dependency issues first to resolve the class loading issue, your aspectj config looks correct to me even though I doubt if the point cut expression will work.

am not sure which dependencies or class loading are a problem, all works well without aspectj which makes me doubt if its not it causing issues even when logs are not straight

I think the issue has to do with the way proxies are handled in spring i.e cglib vs jdk proxies, those offending classes from the app framework module in the logs don’t implement any interface so they are autowired by the target class.

1 Like

now u are getting to my problem, any recommendations on how to resolve this proxy conflict

how is this in your evaluation of this blocker then?

CC: @dkayiwa, @wyclif, did u guys see my above response?

I thought you were doing a throw away module to reproduce the problem.

sorry just found some time to do that, here is the throw away module it actually looks like its now a classloading issue that i can’t figure out why it happens with aspectj on my classpath in the shortest time i had to check it out again

Looks like you’re missing the apsectjrt library that contains that class.

that happens even with apsectjrt, i also tried various libraries that provide aspectj

Sometimes saying it doesn’t work even when I add it isn’t enough, because we don’t know exactly what you are doing or what mistake you could be making.

FYI, I don’t seem to see it in the pom file of the project you shared anyways, sometimes if you have duplicate libraries you end up with class loading issues too, you might want to use maven dependency tree plugin to first confirm that it’s not included, before you add it.