Announcement Announcement Module
Collapse
No announcement yet.
Error creating bean .... AspectException: null Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error creating bean .... AspectException: null

    Hi everyone,

    I started with Spring framework a few weeks ago and I got stuck on the following error:

    Error creating bean with name 'myManager' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException: null

    This happened to me when I wanted to use the magical AOP and org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean class.

    It took me a very long time to find out what is wrong. 'null' is a very good hint indeed.

    Firstly I thought that I have found the same problem and also solution to that problem here: http://forum.springframework.org/showthread.php?t=9824 but I was already using the latest 1.1 release. Configuration used in topic 278 was very similar to mine except I like using constructors rather than properties and setters to initialise my beans.

    Only to provide some facts here is my application context:

    Code:
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> 
    
    <beans> 
    
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
            <property name="url"><value>jdbc:hsqldb:SimpleBean</value></property>
            <property name="username"><value>sa</value></property>
            <property name="password"><value></value></property>
        </bean>
    
        <!-- Hibernate SessionFactory -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
            <property name="dataSource"><ref local="dataSource" /></property>
            <property name="mappingResources">
            <list>
                <!-- Add list of .hbm.xml files here -->
                <value>SimpleBean.hbm.xml</value>
            </list>
            </property>
            <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">net.sf.hibernate.dialect.HSQLDialect</prop>
                <!-- Hibernate Connection Pool -->
                <prop key="hibernate.connection.pool_size">1</prop>
                <prop key="hibernate.dbcp.maxActive">4</prop>
                <prop key="hibernate.dbcp.whenExhaustedAction">1</prop>
                <prop key="hibernate.dbcp.maxWait">120000</prop>
                <prop key="hibernate.dbcp.maxIdle">10</prop>
                <!-- prepared statement cache --> 
                <prop key="hibernate.dbcp.ps.maxActive">4</prop>
                <prop key="hibernate.dbcp.ps.whenExhaustedAction">1</prop>
                <prop key="hibernate.dbcp.ps.maxWait">120000</prop>
                <prop key="hibernate.dbcp.ps.maxIdle">10</prop>
                <prop key="hibernate.connection.provider_class">net.sf.hibernate.connection.DBCPConnectionProvider</prop>
                <!-- Second-level Cache -->
                <prop key="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</prop>
                <prop key="hibernate.cache.use_minimal_puts">true</prop>
                <prop key="hibernate.cache.region_prefix">hibernate.test</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
            </props>
            </property> 
        </bean>
    
        <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> 
        <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
            <property name="sessionFactory"><ref local="sessionFactory" /></property>
        </bean>
    
        <!-- Add DAOs here --> 
        <bean id="hibernateDAO" class="SimpleDAO">
            <property name="sessionFactory"><ref local="sessionFactory" /></property>
        </bean>
    
        <!-- Add Managers Target Proxies here --> 
        <bean id="myManagerTarget" class="SimpleManager">
            <!--<property name="hibernateDao"><ref local="hibernateDAO" /></property>-->
    	<constructor-arg>
    	    <ref bean="hibernateDAO"/>
    	</constructor-arg>
        </bean>
    
        <!-- Add Managers Proxies here --> 
        <bean id="myManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="transactionManager"><ref local="transactionManager" /></property> 
            <property name="target"><ref local="myManagerTarget" /></property> 
            <property name="transactionAttributes">
            <props>
                <prop key="insert">PROPAGATION_REQUIRED</prop>
                <!--
                <prop key="update">PROPAGATION_REQUIRED</prop>
                <prop key="delete">PROPAGATION_REQUIRED</prop>
                -->
                <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
            </props>
            </property>
        </bean>
    
    </beans>

    Look at "myManagerTarget". If the SimpleManager class has not got a default public constructor
    Code:
    public SimpleManager() {}
    but only this constructor is not enough!
    Code:
    public SimpleManager(SimpleDAO dao)
    {
      _dao = dao;
    }
    funny thing is that a setter method does not have any impact on this. It does not have to be present.

    than you get "org.aopalliance.aop.AspectException: null"

    I am not sure if this is a feature or a defect although from my point of view it's a defect somewhere. Conclusion is that if such powerful frameworks works well then hurrah and if something goes wrong than you get stuck for hours if not for days (in this case).

    Am I the only one who had this problem? Or is this a very well documented feature and I am the last person on this planet who did not know?

    Ta[/code][/url]
    Last edited by robyn; May 14th, 2006, 10:08 AM.

  • #2
    I think this is the same erorr, which is fixed in Spring 1.1.1, just released yesterday:

    http://forum.springframework.org/sho...d.php?t=10539=
    Last edited by robyn; May 14th, 2006, 10:09 AM.

    Comment


    • #3
      Actually, I think you're hitting the limitation mentioned in this JIRA bug/feature request, which is still to be resolved (this week or next, as far as I can tell).

      http://opensource.atlassian.com/proj...browse/SPR-285

      Comment


      • #4
        Thanks for you reply Colin.

        I just tried version 1.1.1 and it is still a problem.

        Comment

        Working...
        X