Announcement Announcement Module
Collapse
No announcement yet.
Superclass has no null constructors but no arguments were given Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Superclass has no null constructors but no arguments were given

    Hi.

    Recently I switched from TransactionProxyFactoryBean proxies to annotation based transaction handling via @Transactional. Now I encounter on a class, that has no default constructor the exception:

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookingSystemManager' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class foo.bar.BookingSystemManagerImpl]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
    Caused by: 
    org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class de.reservento.backend.business.bookingsystem.BookingSystemManagerImpl]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
    Caused by: 
    java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
    	at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718)
    	at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
    	at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
    	at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
    	at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
    	at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
    	at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
    	at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:197)
    	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:429)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:299)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:313)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1181)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:757)
    	at de.reservento.backend.util.SpringContext.getBean(SpringContext.java:19)
    	at de.reservento.backend.business.BusinessService.getBookingSystemManager(BusinessService.java:32)
    	at de.reservento.backend.business.system.SystemManagerImpl.initialize(SystemManagerImpl.java:293)
    	at de.reservento.backend.business.system.SystemManagerImpl.startup(SystemManagerImpl.java:238)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:267)
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:585)
    	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
    That is weird since my configuration looks like this:

    Code:
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="false"/>	
    <aop:config proxy-target-class="false"/>
    
    <bean id="bookingSystemManager" class="foo.bar.BookingSystemManagerImpl" destroy-method="destroy">
    	<property name="audit" ref="auditLog" />
    	<constructor-arg>
    		<ref bean="pluginRegistry"/>
    	</constructor-arg>
    </bean>
    So since the error is cglib related, and AFAIK cglib requires a default constructor, somehow spring means to use cglib proxies instead of JDK ones. I have already set proxy-target-class="false" explicit (see above) to avoid this - with no luck.

    One reason is, that the class does not implement an interface. But it does:

    Code:
    public class BookingSystemManagerImpl implements BookingSystemManager
    I also double checked, that I have no @Transactional on private or non-interface methods in the Impl class that might lead to cglib usage.

    When I remove the @Transactional from the class, it startsup without any problem. If I add one @Transactional, it immediately breaks.

    Any hints what I can additionally check?

    BTW: I use spring 2.0.5 with JDK 5 - already tried 2.0.8 with the same problem.

    Regards,
    Veit

  • #2
    This looks like a bug. Can you try the latest version of Spring (2.5.4)?

    -Ramnivas

    Comment


    • #3
      Made an ugly (new ehcache 1.4.1 needs jsr107 api now, new springmvc.jar dependcy) upgrade to spring 2.5.4. Still the same error message.

      Any hints?

      Comment


      • #4
        Please file a bug and I will take a look. If you can attach a reproducible test case, that will be helpful.

        -Ramnivas

        Comment


        • #5
          While creating a testcase project (which is no fun setting up dataSources, resolving dependencies etc.) I stumbled across another aop setting in one of my applicationContext files:

          Code:
          <aop:aspectj-autoproxy proxy-target-class="true" />
          I added this a while ago for logging entering/leaving specific methods and forgot about that. Switching this setting to false (like the other AOP configs), makes the error message "Superclass has no null constructors but no arguments were given" disappear.

          So my question is now, why using @Transactional has something todo with this setting? Is this expected behavior?

          Comment

          Working...
          X