If your target class does not implement an interface Spring uses the CGLIB library to generate a subclass to the target class When creating the subclass Spring creates Advice delegates calls for subclass to Target class you will need to deploy all of cglib to lib/cglib folder
if the target object uses interfaces to implement the methods you will need to use java.lang.reflect.Proxy methods marked as final cannot be advised Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > From: [email protected] > Date: Mon, 6 Jul 2009 12:21:44 -0700 > Subject: Re: surefire and spring - Autowiring of methods failed > To: [email protected] > > I've run into the same problem with Cobertura and Spring - what seemed to > fix it was, in the context file, changing <aop:config> to <aop:config > proxy-target-class="true">. I'm not entirely sure *why* that worked (I dealt > with this a couple months ago, and it required a *lot* of googling to get > any kind of idea of what to do, so I don't remember all the details), but > that did the trick. > > A. > > On Mon, Jul 6, 2009 at 6:26 AM, Chávez, Carlos <[email protected]> wrote: > > > > We have found that SpringJUnit4ClassRunner is not compatible with the > > > 4.5+ versions of JUnit. > > > > > > I think that you will find that in > > > > > > private UsuarioFacade usuarioFacade; > > > > > > that UsuarioFacade must be an interface in order for Spring to do it's > > > magic. Is this the case? > > > > > > This does not explain why the problem only manifests itself during > > > "mvn site", and not "mvn install" or "mvn test". > > > > > > Did it seem to work with JUnit 4.6 at all? If it did, then you unit > > > tests were not executing because this combination cannot work. > > > > > > What version of Maven are you using? > > > > > > Cheers, > > > > > > Steve C > > > > > > > Hi Steve. > > > > I'm using Apache Maven 2.2.0 (r788681; 2009-06-26 07:04:01-0600). > > > > Yes, I used too the junit 4.6 and for test or install goals works very > > well, > > for "site" plugin show the following exception: > > > > org.apache.maven.surefire.booter.SurefireExecutionException: > > > > org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V; > > nested exception is java.lang.NoSuchMethodError: > > > > org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V > > java.lang.NoSuchMethodError: > > > > org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V > > > > that is why I switched to junit 4.4 version. > > > > > > Now, i think i found was is causing the issue, I think it is the cobertura > > maven plugin. My understanding is: The cobertura instruments the classes, > > so > > The cobertura tried to set a proxied object ($Proxy17) which of course is > > not > > of the type expected (UsuarioFacade), the error is: > > > > GRAVE: Caught exception while allowing TestExecutionListener > > > > [org.springframework.test.context.support.dependencyinjectiontestexecutionliste...@18eb7b8 > > ] > > to prepare test instance > > [null(ni.gob.cgr.siirci.facade.UsuarioFacadeTestCase)] > > org.springframework.beans.factory.BeanCreationException: Error creating > > bean > > with name 'ni.gob.cgr.siirci.facade.UsuarioFacadeTestCase': Injection of > > resource methods failed; nested exception is > > org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean > > named > > 'usuarioFacade' must be of type [ni.gob.cgr.siirci.facade.UsuarioFacade], > > but > > was actually of type [$Proxy17] > > at > > > > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:305) > > at > > > > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:998) > > at > > > > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329) > > at > > > > org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110) > > at > > > > org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) > > at > > > > org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255) > > at > > > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111) > > at > > > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148) > > at > > > > org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61) > > at > > > > org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:54) > > at > > org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) > > at > > org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) > > at > > org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:52) > > at > > > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97) > > at > > > > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) > > at > > > > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) > > at > > > > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) > > at org.apache.maven.surefire.Surefire.run(Surefire.java:177) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at > > > > org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) > > at > > > > org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) > > Caused by: > > org.springframework.beans.factory.BeanNotOfRequiredTypeException: > > Bean named 'usuarioFacade' must be of type > > [ni.gob.cgr.siirci.facade.UsuarioFacade], but was actually of type > > [$Proxy17] > > at > > > > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) > > at > > > > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) > > at > > > > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168) > > at > > > > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:435) > > at > > > > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409) > > at > > > > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:537) > > at > > > > org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:192) > > at > > > > org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117) > > at > > > > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:302) > > ... 23 more > > org.apache.maven.surefire.booter.SurefireExecutionException: > > > > org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V; > > nested exception is java.lang.NoSuchMethodError: > > > > org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V > > java.lang.NoSuchMethodError: > > > > org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V > > at > > > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:155) > > at > > > > org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61) > > at > > > > org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:54) > > at > > org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) > > at > > org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) > > at > > org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:52) > > at > > > > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97) > > at > > > > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) > > at > > > > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) > > at > > > > org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) > > at org.apache.maven.surefire.Surefire.run(Surefire.java:177) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > at > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at > > > > org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) > > at > > > > org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) > > > > -- > > Cheers. > > Carlos Chávez. > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > _________________________________________________________________ Windows Live™: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_BR_life_in_synch_062009
