Results 1 to 6 of 6

Thread: proxyTargetClass using OJB

  1. #1
    Join Date
    Sep 2004
    Posts
    13

    Default proxyTargetClass using OJB

    Hi,

    I'm using spring's transactionmanagement with OJB 1.0. When trying to use a class rather than an interface I retrieve the following exception.
    Configuration is:

    Code:
    	<bean id="ojbConfigurer" class="org.springframework.orm.ojb.support.LocalOjbConfigurer"/>
    	<bean id="myTransactionManager" class="org.springframework.orm.ojb.PersistenceBrokerTransactionManager"/>
    	<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
    			abstract="true" >
    		<property name="transactionManager"><ref bean="myTransactionManager"/></property>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    				...
    			</props>
    		</property>
    	</bean>
    
    	<bean id="accessMng" parent="baseTransactionProxy" >
    		<property name="target" >
    			<bean class="eg.model.mng.AccessMngOjbImpl" />
    		</property>
    		<!-- this line causes the exception -->
    		<property name="proxyTargetClass"><value>true</value></property> 
    	</bean>
    Thanks for any help !
    Leo

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'accessMng' defined in class path resource [applicationContext-ojb.xml]: Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException: null
    net.sf.cglib.core.CodeGenerationException: java.lang.IllegalArgumentException-->Protected method: createPersistenceBrokerTemplate()Lorg/springframework/orm/ojb/PersistenceBrokerTemplate;
    at net.sf.cglib.core.ReflectUtils.newInstance(Reflect Utils.java:235)
    at net.sf.cglib.core.ReflectUtils.newInstance(Reflect Utils.java:220)
    at net.sf.cglib.core.ReflectUtils.newInstance(Reflect Utils.java:216)
    at net.sf.cglib.proxy.Enhancer.createUsingReflection( Enhancer.java:566)
    at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer .java:493)
    at net.sf.cglib.core.AbstractClassGenerator.create(Ab stractClassGenerator.java:220)
    at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer. java:368)
    at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:2 80)
    at org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:171)
    at org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:136)
    at org.springframework.aop.framework.ProxyFactory.get Proxy(ProxyFactory.java:66)
    at org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean.afterPropertiesSet(Transacti onProxyFactoryBean.java:236)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:991)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:288)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:208)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:204)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:224)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:284)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:80)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:65)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:56)

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Leo,

    Can you post the code for your AccessMngOjbImpl class. I have tried reproducing this with a simple example but I have been unable to do so. Also which version of Spring and CGLIB are you using?

    Rob

  3. #3
    Join Date
    Sep 2004
    Posts
    13

    Default

    Hi Rob,

    I'm using spring 1.1 and cglib-full-2.0.2. The code is:
    public class AccessMngOjbImpl extends PersistenceBrokerDaoSupport implements AccessMng {
    public void updateUser(AppUser user) throws MyException {
    if (user.getFirstname() == null)
    throw new MyException("firstname is not set for user: " + user.getId());
    getPersistenceBrokerTemplate().store(user);
    }
    ...
    }

    Leo

  4. #4
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Leo,

    Thanks for that. I am able to reproduce this bug on my machine. I will look into it a little more. I have created an issue on JIRA so you can track the progress: http://opensource.atlassian.com/proj...browse/SPR-357.

    For now I recommend that you use JDK proxies by removing the proxyTargetClass property.

    Rob

  5. #5
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Leo,

    This is now fixed in CVS and the fix will make its way into 1.1.1 which will be released fairly soon.

    Rob

  6. #6
    Join Date
    Sep 2004
    Posts
    13

    Default

    Hi Rob,

    thank you for the quick help !!

    Leo

Similar Threads

  1. Replies: 7
    Last Post: Oct 22nd, 2005, 07:28 AM
  2. Replies: 0
    Last Post: May 4th, 2005, 10:23 PM
  3. Replies: 1
    Last Post: Mar 22nd, 2005, 01:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •