Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8706037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:30:50+00:00 2026-06-13T03:30:50+00:00

Using cglib proxies in spring causes: a) double invocation of constructor b) not allow

  • 0

Using cglib proxies in spring causes:

a) double invocation of constructor

b) not allow to intercept a method invoked from another method

but why spring creates a bean and then a proxy? is it possible to dynamically generate class that extends a specified bean class and then invoke constructor only once? that would solve a) and b) for public and protected methods. am i missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:30:52+00:00Added an answer on June 13, 2026 at 3:30 am

    Good question. I think it’s due to how Spring bootstraps application context: it first creates all raw beans and then applies post processors, e.g. adding AOP (including transactions). This layered architecture requires creating normal bean first and then wrapping it. One might argue that this approach follows composition over inheritance principle.

    Also note that a) should not be a problem. Class should not perform initialization in constructor but in @PostConstruct method – which is invoked only once. On the other hand this leads to another issue:

    c) one cannot use constructor injection with CGLIB proxies, see SPR-3150

    But I understand your frustration. Guess the only valid workaround is to us full AspectJ weaving.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring app with aop enabled using cglib proxies for logging: <?xml
I am using cglib to enhance a HashMap so I can intercept method calls
I'm developing web application supported by Spring Integration. I'm using 1.0.4.RELEASE. I use CGLib
When creating proxies in CGLib using Enhancer, you can call .setNamingPolicy(NamingPolicy n) to change
When creating proxies in CGLib using Enhancer, you can call .setNamingPolicy(NamingPolicy n) to change
I want to filter out certain lines from stack traces using log4j (like net.sf.cglib.*
I have noticed from several web pages that apparently Spring 3.0 supports @Inject from
I have a fairly odd set of circumstances. I'm using Spring 3.0.6 with a
I have not been using envers for very long, and i have hit a
I am creating a web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.