question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default CGLib proxy setting default cannot be overridden by using core framework annotations (@EnableTransactionManagement, @EnableAspectJAutoProxy)

See original GitHub issue

Spring Boot 2.0 changes the default value for the configuration property spring.aop.proxy-target-class to true if nothing is configured. This causes an explicit @EnableAspectJAutoProxy(proxy-target-class = false) not being picked up anymore. Also an explicit @EnableTransactionManagement(proxy-target-class = false) is not causing transactional proxies being created as JDK proxies anymore as the default true gets applied.

I.e. you see the same symptoms as described in #8434.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
odrotbohmcommented, Feb 23, 2018

That’s sorry to hear as as far as I can see, this is the first occasion that I encounter, that Boot doesn’t respect standard Spring user configuration, which breaks the “Boot fills configuration gaps and respects what you’ve configured explicitly.” story.

Regarding the “aren’t needed in a Boot app” statement. I don’t think I can agree with this. If you want to ship code that by definition can’t use CGLib proxies (e.g. because the code is deliberately using interfaces to allow final methods in the interface implementation) and you want to make sure that this code works as expected, shipping a configuration class that enforces JDK proxies is a reasonable option. Relying on someone downstream configuring the property in a special way is cumbersome as it creates much bigger distance between the code that needs the setting and where the setting is configured.

I haven’t been too happy with the switch to CGLib proxies by default in the first place as CGLib still imposes quite severe limitations on the code being written. That switch in default that was basically a convenience switch and was considered to not have any implications now basically leads to one of Boot’s core principles to be undermined. Even worse, we break the usually pretty helpful Spring Framework error messages as the log output you get in the error case suggests to set proxyTargetClass to false which is exactly what you have in place and thus probably leaves you puzzled as nothing leaves a trace that some Boot default affects this and we’ve spent years training users to expect their custom configuration trump Boot’s defaults.

0reactions
snicollcommented, Jan 2, 2019

@amol204 please don’t comment on a closed issue to get support. If you have a question please ask on StackOverflow or come chat with the community on Gitter. Also, Shiro is not handled here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring-Boot 2+ forces CGLIB proxy even with ... - Stack Overflow
It's a known issue. Currently you can only set spring.aop.proxy-target-class=false. in your config file to force it to use JDKProxy.
Read more >
Configuration (Spring Framework 6.0.2 API)
Enabling built-in Spring features using @Enable annotations​​ See @EnableAsync , @EnableScheduling , @EnableTransactionManagement , @EnableAspectJAutoProxy , and ...
Read more >
惊人!Spring5 AOP 默认使用Cglib? 从现象到源码深度分析
issue:Default CGLib proxy setting default cannot be overridden by using core framework annotations (@EnableTransactionManagement, ...
Read more >
Spring cert study Flashcards - Quizlet
To enable component scanning, annotate a configuration class in your Spring application with the @ComponentScan annotation. The default component scanning ...
Read more >
Core Technologies - simviso
By default, when the Spring container creates a proxy for a bean that is marked up with the <aop:scoped-proxy/> element, a CGLIB-based class ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found