-
Notifications
You must be signed in to change notification settings - Fork 31
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
Enhancing @Transactional service gives groovy.lang.MissingMethodException #68
Comments
Hi Chris, we don't have documentation for supported method signatures but in my opinion we should try to support any signature. Just by curiosity, does your service works with this signature if you're not using Melody plugin? |
Hi Sergio, yes it works fine, when Melody plugin is OFF. I found this problem when I was refactoring legacy code and replacing method's parameters types from def to concrete types. When I switched def to Class my integration tests (IT) stopped working. When I turned OFF Melody IT worked fine even after refactoring. |
So I was checking this behavior and looks like an issue (or maybe expected behavior?) with meta class. Currently we rely on Without Grails Melody plugin your service call will work because there's no Maybe we could use Spring AOP instead of meta class , but this needs more time to investigate. For now unfortunately you'll have to change your method signature. |
I too have just run into this error working on bug, found when upgrading to Grails 3.3.9. While I like Melody, for taking a look at performance, I've found, that leaving it on all the time can run into issues. It also have a tendency to breaking the debugger, so I often run with it off when running locally. Another idea would be to look into compile-time metaprogramming, vs the runtime variety. Possibly using a global AST transform. This would probably be a big undertaking though, as ASTs are a bit more complex than the runtime metaprogramming. |
So after a little more investigation, this only seems to happen, when I have an @transactional, on a method, that has a parameter of type Class. I don't know it that will help any though. |
Ok, I started playing with it and converting to an AST might not be that hard. The only difficulty is getting the configuration to the AST, when in my experience, I've only been able to pull off by setting a system property in a custom compiler script. So from the MelodyInterceptorEnhancer it looks like that just intercepts every call to methods in services, and adds a call to |
@virtualdogbert Can you share a branch with your changes? Then I can take a look in your issue. |
@sergiomichels Ok I'll gather up what I have tonight, push it to github, and send you links. Like I said the big thing I was missing from a testing stand point was how to get The only reason I hit you up on slack was because it had been over a month since I posted this, now it's two. Although I totally understand about being busy, I have to get back to some of my side projects as well... |
@virtualdogbert There's a bug in Plugin mimics Melody's
|
@sergiomichels So I put my idea for replacing the runtime programming with an AST Transform here: I also created a test app here: I didn't make the AST configurable, at this point, I just commented out the runtime metaprogramming in the plugin and used the AST. However I still don't know how to get the spring monitoring going, through the config, it doesn't seem to hit the class that you mention... I can make it so that it could be a choice between the AST way and the runtime metaprogramming way similar to how I made the Enterprise Groovy Gradle plugins AST configurable, using a compiler script. |
@virtualdogbert this interceptor class is not used by grails melody, the goal of runtime metaprogramming is to have same logic, so init from interceptor should be copied to plugin bootstrap. |
Grails 3.3.8 / JDK1.8.0_192 / Win OS / grails-melody-plugin 1.74.0
When adding new Service class:
and extending test from app-integration-tests like this
gives:
Looks like first argument's type Class makes all the troubles.
When switched to Object works OK and metaMethod is found in MelodyInterceptorEnhancer:
Does it look like a bug to you or is it documented somewhere
(NOT to use certain method signatures to be properly enhanced by Melody)?
Chris
The text was updated successfully, but these errors were encountered: