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

  • Home
  • SEARCH
  • 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 8512663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:20:35+00:00 2026-06-11T04:20:35+00:00

I want to use Spring AOP in my spring application. While creating AOP proxy

  • 0

I want to use Spring AOP in my spring application. While creating AOP proxy for net.sf.ehcache.CacheManager, spring context initialization fails with the below exception:

nested exception is org.springframework.aop.framework.AopConfigException: Could not
generate CGLIB subclass of class [class net.sf.ehcache.CacheManager]: Common causes of 
this problem include using a final class or a non-visible class; nested exception is 
net.sf.cglib.core.CodeGenerationException: net.sf.ehcache.CacheException-->Another   
unnamed CacheManager already exists in the same VM. Please provide unique names for 
each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same  
CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.
The source of the existing CacheManager is: InputStreamConfigurationSource 
[stream=java.io.ByteArrayInputStream@955b34]

Here’s my understanding about this problem – Spring is trying to create AOP proxy for net.sf.ehcache.CacheManager, and it succeeds the first time and gives a default name to the CacheManager __DEFAULT__ (found this by adding debug statements to ehcache code, building it by source and using that in my application). Now if I’ve multiple cache managers like ‘abcCacheManager’ and ‘xyzCacheManager’ (of type EhCacheManagerFactoryBean), Spring encounters multiple net.sf.ehcache.CacheManagers and tries to create proxy objects (something like net.sf.ehcache.CacheManager$$EnhancerByCGLIB$$b18c5958) for all of them, but with EhCache >=2.5 version, we can’t have more than one caches with same name under the same VM.

I’m using EhCache 2.5.1 and would like to avoid going back to 2.4 just for this purpose. I’m not sure if this is really the problem how I can overcome this problem.

Note: Note sure if this will help, but I also noticed from the debug statements that CacheManager no-arg constructor is invoked only by the spring/CGLIB proxy generator and xyzCacheManager invokes it by passing configuration as argument.

  • 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-11T04:20:37+00:00Added an answer on June 11, 2026 at 4:20 am

    Note : I’m answering this myself as it may help others who face the same problem.

    jeha‘s comment on my question makes sense as I shouldn’t have needed that proxy at the first place, but since I’m new to Spring AOP and proxies, I didn’t know how auto-proxy mechanism works. As I modified the pointcut expressions in my advice, I didn’t face the above problem after that. Prior to this, almost all the beans in the container were getting proxied and hence the problem.

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

Sidebar

Related Questions

I want to use cglib as my proxy mechanism for spring. problem is, i
I'm creating spring.net proxy in code by using ProxyFactory object with ProxyTargetType to true
I want to use Spring inside a legacy application. The core piece is a
I want to use Spring framework to create application that uses Oracle 11g to
I am working on a application using spring. i want to use spring validation
I want to use Spring 3 for validation. In the reference documentation, section 6.2
I came from the Spring camp , I don't want to use Spring ,
I want to use two different Spring web contexts , each have own contextConfig,
I've recently started upgrading some applications to use Spring Webflow 2, and I want
I want to use @PreAuthorize annotation on service methods with Spring Security. One of

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.