Skip to content
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

Cannot create proxy for spring component without default constructor #232

i-dorofeev opened this Issue Apr 3, 2018 · 2 comments


None yet
3 participants
Copy link

i-dorofeev commented Apr 3, 2018

I receive an error when trying to obtain a bean which class doesn't have a default constructor (has its constructor arguments autowired) from ApplicationContext:

Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given                                                                                                          
  at org.springframework.cglib.proxy.Enhancer.emitConstructors(                
  at org.springframework.cglib.proxy.Enhancer.generateClass(                   
  at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(                                                                                                                 
  at org.springframework.cglib.core.AbstractClassGenerator.generate(                                                                                                                    
  at org.springframework.cglib.proxy.Enhancer.generate(                        
  at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(                                                                                                      
  at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(                                                                                                      
  at org.springframework.cglib.core.internal.LoadingCache$           
  at org.springframework.cglib.core.internal.LoadingCache.createEntry(      
  at org.springframework.cglib.core.internal.LoadingCache.get(              
  at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(                                                                                                         
  at org.springframework.cglib.core.AbstractClassGenerator.create(                                                                                                                      
  at org.springframework.cglib.proxy.Enhancer.createHelper(                    
  at org.springframework.cglib.proxy.Enhancer.create(                          
  at HotswapAgentSpringBeanProxy_1796692748.create(  
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                 
  at sun.reflect.NativeMethodAccessorImpl.invoke(               
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(       
  at java.lang.reflect.Method.invoke(                                            
  at org.hotswap.agent.plugin.spring.getbean.EnhancerProxyCreater.create(                                                                                                                  
  at org.hotswap.agent.plugin.spring.getbean.EnhancerProxyCreater.createProxy(                                                                                                             
  at org.hotswap.agent.plugin.spring.getbean.ProxyReplacer.register(       

This comment has been minimized.

Copy link

Gebon commented Apr 23, 2018


edudant pushed a commit that referenced this issue May 7, 2018


This comment has been minimized.

Copy link

edudant commented May 7, 2018

Proxy of a class without default constructor is supported from Spring4:
// Spring 4: CGLIB-based proxy classes no longer require a default constructor. Support is provided
// via the objenesis library which is repackaged inline and distributed as part of the Spring Framework.
// With this strategy, no constructor at all is being invoked for proxy instances anymore.

For more explanation see

I have replicated Spring solution with Objenesis library.

@edudant edudant closed this May 7, 2018

edudant pushed a commit that referenced this issue May 16, 2018

Jiří Bubník
#232 - do not know why Spring 4.2.6 AND 4.3.0 does not work, probably…
… cglib version and cache problem. Proxy of class without default constructor NOT supported for theses versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.