1234
Oct 1st, 2004, 06:49 AM
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:
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource">
<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.LocalSessionFact oryBean">
<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.HibernateTransac tionManager">
<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.Transa ctionProxyFactoryBean">
<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
public SimpleManager() {}
but only this constructor is not enough!
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]
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:
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource">
<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.LocalSessionFact oryBean">
<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.HibernateTransac tionManager">
<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.Transa ctionProxyFactoryBean">
<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
public SimpleManager() {}
but only this constructor is not enough!
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]