|
From: Colin S. <col...@ex...> - 2004-01-28 20:04:56
|
The class is not final, and there are no final methods. And I was wrong, it actually already implemented one interface, InitializingBean. I was definitely wrapping the right object, as afterwards I added a new service interface to the object, took out the proxyTargetClass property, and everything is now working fine. Unfortunately I need to get this code working and deployed today/tomorrow, so adding the interface was the easiest solution. In a day or two I can try to reproduce this in a test case... Rod Johnson wrote: >I saw this once only and it was my fault (accidentally wrapped a String as >the target, rather than real object). > >Are any of the methods, or the object itself, final? > >Can you reproduce this in a failing test case so I can look at it? There >certainly should be a better error message, even if it's a CGLIB prob. > >Regards, >Rod > >----- Original Message ----- >From: "Colin Sampaleanu" <col...@ex...> >To: <spr...@li...>; ><rod...@in...> >Sent: Wednesday, January 28, 2004 1:20 PM >Subject: Proxying target classes > > > > >>Rod, >> >>Have you ever seen cglib's EnhancerEmitter blow up on trying to create a >>proxy? I generally only have to proxy interfaces, so have not proxied >>classes too much so far, however I just had a case where I needed to >>proxy a class directly, and got the following exception: >> >> method 'onMessage' due to throwable >>[org.springframework.beans.factory.BeanCrea >>tionException: Error creating bean with name 'packaging-engine' defined >>in class >>path resource [packaging-applicationContext.xml]: Initialization method >>of bean >>failed; nested exception is: >> org.springframework.aop.framework.AopConfigException: Unexpected >>AOP exc >>eption; nested exception is: >> java.lang.NullPointerException] >>08:07:48,585 INFO [JtaTransactionManager] Initiating transaction rollback >>08:07:48,585 ERROR [LogInterceptor] RuntimeException: >>org.springframework.beans.factory.BeanCreationException: Error creating >>bean wit >>h name 'packaging-engine' defined in classpath resource >>[packaging-applicationCo >>ntext.xml]: Initialization method of bean failed; nested exception is: >> org.springframework.aop.framework.AopConfigException: Unexpected >>AOP exc >>eption; nested exception is: >> java.lang.NullPointerException >>org.springframework.aop.framework.AopConfigException: Unexpected AOP >>exception; >>nested exception is: >> java.lang.NullPointerException >>java.lang.NullPointerException >> at >>net.sf.cglib.proxy.EnhancerEmitter$4.getMethods(EnhancerEmitter.java: >>407) >> at >> >> >net.sf.cglib.proxy.NoOpGenerator.generate(NoOpGenerator.java:69) > > >> at >>net.sf.cglib.proxy.EnhancerEmitter.emitMethods(EnhancerEmitter.java:4 >>31) >> at >>net.sf.cglib.proxy.EnhancerEmitter.<init>(EnhancerEmitter.java:172) >> >>This is using BeanNameAutoProxyCreator, with proxyTargetClass set to >>true. I actually used another postprocessor just for this case, since >>normally I only care about interfaces, so there's nothing else in it: >> >> <bean id="packaging-txAutoProxyCreator2" >> >> >> >class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator" > > >> <property name="proxyTargetClass"><value>true</value></property> >> <property name="interceptorNames"> >> <list> >> <idref bean="hibInterceptor"/> >> <idref local="packaging-matchAllTxInterceptor"/> >> </list> >> </property> >> <property name="beanNames"> >> <list> >> <idref local="packaging-engine"/> >> </list> >> </property> >> </bean> >> >>The class in question (Engine) is a fairly simple class. It implements >>no interfaces. >> >>Regards, >>Colin >> >> >> >> > > > |