Announcement Announcement Module
Collapse
No announcement yet.
Error Initializing TransactionProxyFactoryBean - Please Help Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error Initializing TransactionProxyFactoryBean - Please Help

    Hey All,

    I'm having a problem plugging Hibernate into my application. I'm getting a java.lang.IllegalStateException error.

    Code:
    16:04:05,032 ERROR [ContextLoader] Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'casApplication' defined in resource [/WEB-INF/applicationContext.xml] of ServletContext: Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException: null
    java.lang.IllegalStateException: Callback Lnet/sf/cglib/proxy/MethodInterceptor; is not assignable to Lnet/sf/cglib/proxy/MethodInterceptor;
    	at net.sf.cglib.proxy.Enhancer.validate(Enhancer.java:374)
    	at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:399)
    	at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:318)
    	at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:175)
    	at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:138)
    	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:66)
    It throws this when it tries to initialize my ApplicationImpl bean. Here is my ApplicationContext.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <!-- ======================= APPLICATION CONFIGURATION ==================== -->
    	
    	<!-- Configurer that replaces $&#123;...&#125; placeholders with values from properties files -->
    	<!-- &#40;in this case, mail and JDBC related properties&#41; -->
    	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="locations">
    			<list>
    				<value>/WEB-INF/jdbc.properties</value>
    			</list>
    		</property>
    	</bean>
    	
    	<!-- a parent bean definition which is a 'template' or base definition for
    	     transaction proxies. It is set as lazy-init, since it is never
    		 supposed to be instantiated itself. -->
    	<bean id="baseTxProxy" lazy-init="true"
    	      class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    		<property name="transactionManager"><ref bean="myTransactionManager"/></property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="*">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<!-- LockNLoad's primary business object &#40;default implementation&#41;, as an
    	     inner bean wrapped by an outer transactional proxy. The two bean
    		 definitions could have been separate, but this is cleaner as there
    		 is no need to ever access the unwrapped object.
    		 Note that we override the transaction propagation settings from the
    		 parent 'baseTxProxy' definition -->
    	<bean id="casApplication" parent="baseTxProxy">
    		<property name="target"><ref bean="casApplicationImpl"/></property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="store*">PROPAGATION_REQUIRED</prop>
    			</props>
    		</property>
    	</bean>
    	
    	<bean name="casApplicationImpl" class="com.sccc.cas.domain.CasApplication">
    		<property name="dao"><ref bean="myDao"/></property>
    	</bean>
    	
    	
    </beans>
    And here is my hibernate.xml configuration...

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <!-- ========================= RESOURCE DEFINITIONS ========================= -->
    
    	<!-- Local DataSource that refers to a combined database -->
    	<!-- The placeholders are resolved from jdbc.properties through -->
    	<!-- the PropertyPlaceholderConfigurer in applicationContext.xml -->
    	<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    		<property name="driverClassName"><value>$&#123;jdbc.driverClassName&#125;</value></property>
    		<property name="url"><value>$&#123;jdbc.url&#125;</value></property>
    		<property name="username"><value>$&#123;jdbc.username&#125;</value></property>
    		<property name="password"><value>$&#123;jdbc.password&#125;</value></property>
    	</bean>
    	
    	<!-- Session Factory definition for Hibernate implementation -->
    	<bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    		<property name="dataSource"><ref bean="myDataSource"/></property>
    		<property name="mappingResources">
    			<list>
    				<value>/com/sccc/cas/hibernate/cas.hbm.xml</value>
    			</list>
    		</property>
    		<property name="hibernateProperties">
    			<props>
    				<prop key="hibernate.dialect">$&#123;hibernate.dialect&#125;</prop>
    			</props>
    		</property>
    		
    	</bean>
    	
    	<!-- Transaction manager for a single JDBC DataSource -->
    	<bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
    		<property name="sessionFactory"><ref local="mySessionFactory"/></property>
    	</bean>
    	
    	<!-- ============== DAO DEFINITIONS&#58; HIBERNATE IMPLIMENTATIONS ============== -->
    	
    	<bean id="myDao" class="com.sccc.cas.dao.HibernateDao">
    	 	<property name="sessionFactory"><ref bean="mySessionFactory"/></property>
    	</bean>
    	
    </beans>
    Does anyone know why I might be getting this error?

    Thanks,
    James

  • #2
    James,

    If I remember correctly, I encountered this problem with an older version of CGLIB. Try upgrading to 2.0.2 or 2.1dev. Make sure that this is the only version of CGLIB on your classpath.

    Rob

    Comment


    • #3
      Thank you so much. That was what it was. I didn't even consider it because I have everything working in another application. This application looked identical, so I figured it was something else I was doing. Man I love these forums.

      Thanks,
      James

      Comment

      Working...
      X