PDA

View Full Version : Error creating bean with name 'myManager' defined in ...


valentim
Aug 22nd, 2004, 09:52 PM
Hi folks, 8)

I'm using Spring, Hibernate and Struts on Jbuilder X. :shock:
I created a testCase and when run this test I receive the following message:

org.springframework.beans.factory.BeanCreationExce ption: 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 :?

my applicationContext.xml is:

<!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.firebirdsql.jdbc.FBDriver</value></property>
<property name="url"><value>jdbc:firebirdsql:localhost:...</value></property>
<property name="username"><value>SYSDBA</value></property>
<property name="password"><value>masterkey</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>...</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.FirebirdDialect</prop>

<!-- Hibernate Connection Pool -->
<prop key="hibernate.connection.pool_size">1</prop>
<prop key="hibernate.dbcp.maxActive">100</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">100</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="...HibernateDAO">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<!-- Add Managers Target Proxies here -->
<bean id="myManagerTarget" class="...myManager">
<property name="hibernateDAO"><ref local="hibernateDAO" /></property>
</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>

somebody has some idea of that it is happening? :oops:

TIA

irbouho
Aug 22nd, 2004, 10:50 PM
is your class 'myManager' defined final? CGlib can not proxy final classes.

valentim
Aug 23rd, 2004, 06:55 AM
No, MyManager definition is:

package ...;

import java.util.Set;

import ....HibernateDAO;
import ....myVO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class MyManager {

private static Log log = LogFactory.getLog(MyManager.class);
private HibernateDAO dao;

public void setHibernateDAO(HibernateDAO dao) {
this.dao = dao;
}

public myVO insert(myVO value) {
return (myVO) dao.insert(value);
}

public myVO update(myVO value) {
return (myVO) dao.update(value);
}

public void delete(myVO value) {
dao.delete(value);
}

public myVO find(myVO value) {
return (myVO) dao.find(value, value.getIdentificador());
}

public Set select(myVO value) {
return dao.select(value);
}
}

valentim
Aug 23rd, 2004, 08:07 AM
Hi again, 8)

I caught log of execution of the test in the Jbuilder, I see that everything occurs well until the moment of the creation of the bean 'myManager'.

C:\JBuilderX\jdk1.4\bin\javaw -classpath "..." -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=rodrigo:4281, suspend=y com.borland.jbuilder.unittest.JBTestRunner -socket localhost:4045 ...TestmyManager
INFO - Loading XML bean definitions from class path resource [.../applicationContext.xml]
INFO - Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=5210326]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,hiber nateDAO,myManagerTarget,...,myManager,...]; Root of BeanFactory hierarchy
INFO - 54 beans defined in ApplicationContext [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=5210326]
INFO - No MessageSource found for context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=5210326]: using empty default
INFO - No ApplicationEventMulticaster found for context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=5210326]: using default
INFO - Refreshing listeners
INFO - Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,hiber nateDAO,myManagerTarget,...,myManager,...]; Root of BeanFactory hierarchy]
INFO - Creating shared instance of singleton bean 'dataSource'
INFO - Loaded JDBC driver: org.firebirdsql.jdbc.FBDriver
INFO - Creating shared instance of singleton bean 'sessionFactory'
INFO - Hibernate 2.1.4
INFO - hibernate.properties not found
INFO - using CGLIB reflection optimizer
INFO - Mapping class: myVO1 -> TABLE_1
INFO - Mapping class: ... -> ...
INFO - Mapping class: myVO28 -> TABLE_28INFO - Building new Hibernate SessionFactory
INFO - processing one-to-many association mappings
INFO - Mapping collection: ...myVO1.myCollection1 -> TABLE_ABC
INFO - Mapping collection: ... -> ...
INFO - Mapping collection: ...myVO32.myCollection1 -> TABLE_XYZINFO - processing one-to-one association property references
INFO - processing foreign key constraints
INFO - Using dialect: net.sf.hibernate.dialect.FirebirdDialect
INFO - Use outer join fetching: true
INFO - Initializing connection provider: org.springframework.orm.hibernate.LocalDataSourceC onnectionProvider
INFO - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
INFO - Use scrollable result sets: false
INFO - Use JDBC3 getGeneratedKeys(): false
INFO - Optimize cache for minimal puts: true
INFO - Query language substitutions: {}
INFO - cache provider: net.sf.hibernate.cache.HashtableCacheProvider
INFO - instantiating and configuring caches
INFO - building session factory
INFO - no JNDI name configured
INFO - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
INFO - starting query cache at region: net.sf.hibernate.cache.QueryCache
INFO - Creating shared instance of singleton bean 'transactionManager'
INFO - Using DataSource [org.springframework.jdbc.datasource.DriverManagerD ataSource@7f3b8a] of Hibernate SessionFactory for HibernateTransactionManager
INFO - Creating shared instance of singleton bean 'myManagerTarget'
INFO - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
INFO - Creating shared instance of singleton bean 'DB2'
INFO - Creating shared instance of singleton bean 'HSQL'
INFO - Creating shared instance of singleton bean 'MS-SQL'
INFO - Creating shared instance of singleton bean 'MySQL'
INFO - Creating shared instance of singleton bean 'Oracle'
INFO - Creating shared instance of singleton bean 'Informix'
INFO - Creating shared instance of singleton bean 'PostgreSQL'
INFO - Creating shared instance of singleton bean 'Sybase'
INFO - SQLErrorCodes loaded: [HSQL Database Engine, Oracle, Sybase SQL Server, Microsoft SQL Server, Informix Dynamic Server, PostgreSQL, DB2*, MySQL]
INFO - Looking up default SQLErrorCodes for DataSource
INFO - Database Product Name is Firebird
INFO - Driver Version is 0.1
INFO - Error Codes for Firebird not found
INFO - Creating shared instance of singleton bean 'myManager2Target'
INFO - Looking up default SQLErrorCodes for DataSource
INFO - Database product name found in cache for DataSource [org.springframework.jdbc.datasource.DriverManagerD ataSource@7f3b8a]. Name is 'Firebird'.
INFO - Creating shared instance of singleton bean 'myManager25Target'
INFO - Looking up default SQLErrorCodes for DataSource
INFO - Database product name found in cache for DataSource [org.springframework.jdbc.datasource.DriverManagerD ataSource@7f3b8a]. Name is 'Firebird'.

INFO - Creating shared instance of singleton bean 'myManager' <<<< In this point the exception occurs >>>> :roll:

INFO - Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [dataSource,sessionFactory,transactionManager,hiber nateDAO,myManagerTarget,...,myManager,...]; Root of BeanFactory hierarchy}
INFO - Closing Hibernate SessionFactory
INFO - closing
I do not know what he is happening. Somebody can help me?

TIA

Colin Sampaleanu
Aug 23rd, 2004, 09:56 AM
This is a pretty simple setup, similar to what others are already using.

Can you confirm that you are up-to-date w/regards to Spring and CGLib?

Regards,

valentim
Aug 23rd, 2004, 10:56 AM
Hi Colin

This is a pretty simple setup, similar to what others are already using.

Can you confirm that you are up-to-date w/regards to Spring and CGLib?

Regards,

I am working with "spring-framework-1.0.2-with-dependencies.zip" and all jars of the lib directory are in my classpath. 8)
It is necessary to configure more some thing?

TIA

Colin Sampaleanu
Aug 23rd, 2004, 12:11 PM
There were a few cglib related fixes after 1.0.2, although as I remember they were with regards to memory leaks when using prototype objects.

However, you would be well-served by moving to the current code. What's in CVS right now is very stable, and is less than a week or two from release as 1.1 final, so you may want to try it. I've put up a snapshot from today as:

http://web2.springframework.com/snapshots/spring-framework-1.1-with-dependencies-20040823.zip

You could also use 1.1RC2. There have been a few bugfixes since then, but I am pretty sure none of them would be in a related area.

Regards,

valentim
Aug 23rd, 2004, 12:49 PM
Hi Colin,
I will make the tests today, thanks by the attention, I'm very grateful.
I will give notice... :D

TIA

valentim
Aug 23rd, 2004, 10:25 PM
Hi Colin,

Everything is working perfectly, one more time, thank you very much!

Regards,

_________________
Eduardo Valentim

"The best way to learn is to teach"

Colin Sampaleanu
Aug 23rd, 2004, 11:00 PM
So the only thing you changed was dropping in the new version?

Alef Arendsen
Aug 24th, 2004, 09:38 AM
I would be helpful to have a stacktrace here. Although the problem is solved, it might come in handy in case somebody else runs into this problem.

Alef

valentim
Aug 24th, 2004, 01:13 PM
Sorry,

I forgot to say the details. In my classpath I saw that the libraries of the Hibernate (2.1.4) were put in the front of the libraries of the Spring-Framework, then some library that is used for the two frameworks was causing the exception, I believes that it is the CGLib. When I downloaded the version that you ordered me, I cleaned all classpath and remade it using only the new downloaded version of the Spring. 8)

TIA

_________________
Eduardo Valentim

"The best way to learn is to teach"

Colin Sampaleanu
Aug 24th, 2004, 01:21 PM
Ok, so I think this is maybe from just using an out of date cglib jar maybe,