Uploaded image for project: 'Unitils'
  1. Unitils
  2. UNI-248

Unitils Spring fails to inject beans under Java 7

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0, 3.3
    • Fix Version/s: 4.0
    • Component/s: spring
    • Labels:
    • Environment:
      Windows 7, RHEL 6.2, Java 7

      Description

      we're moving an older project to Java 7 and in the process we've found that our tests that use Unitils-Spring fail when unitils tries to inject the beans. Under Java 6, the same tests function properly. It's possible that these issues are related to this bug in Java 7:

      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172865

      Below is the stack trace we're getting:

      0 [main] WARN org.unitils.core.ConfigurationLoader - No custom configuration file unitils.properties found.
      145 [main] INFO org.springframework.context.support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@6fb1d085: display name [org.springframework.context.support.ClassPathXmlApplicationContext@6fb1d085]; startup date [Fri May 31 10:31:54 EDT 2013]; root of context hierarchy
      218 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring-context/eventMessaging-itest-ctx.xml]
      599 [main] INFO org.springframework.context.support.ClassPathXmlApplicationContext - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@6fb1d085]: org.springframework.beans.factory.support.DefaultListableBeanFactory@63920fcc
      654 [main] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@63920fcc: defining beans [org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor#0,common.messaging.simpleConnectionFactory,common.messaging.pooledConnectionFactory,common.messaging.simpleMessageConverter,common.messaging.defaultDestinationResolver,common.messaging.destinationNameResolver,common.messaging.jmsTemplate,common.remoteEventPublisher,common.messaging.jmsEventContainerFactory,common.subscriptionManager]; root of factory hierarchy
      745 [main] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@63920fcc: defining beans [org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor#0,common.messaging.simpleConnectionFactory,common.messaging.pooledConnectionFactory,common.messaging.simpleMessageConverter,common.messaging.defaultDestinationResolver,common.messaging.destinationNameResolver,common.messaging.jmsTemplate,common.remoteEventPublisher,common.messaging.jmsEventContainerFactory,common.subscriptionManager]; root of factory hierarchy
      FAILED CONFIGURATION: @BeforeMethod unitilsBeforeTestSetUp(public void com.example .core.common.event.remote.RemoteEventIntegrationTest.testSingleSubscription())
      org.unitils.core.UnitilsException: Unable to assign the Spring bean value to field annotated with @SpringBeanByType
      at org.unitils.spring.SpringModule.injectSpringBeansByType(SpringModule.java:366)
      at org.unitils.spring.SpringModule$SpringTestListener.beforeTestSetUp(SpringModule.java:459)
      at org.unitils.core.Unitils$UnitilsTestListener.beforeTestSetUp(Unitils.java:273)
      at org.unitils.UnitilsTestNG.unitilsBeforeTestSetUp(UnitilsTestNG.java:62)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
      at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
      at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:653)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      at org.testng.TestRunner.privateRun(TestRunner.java:767)
      at org.testng.TestRunner.run(TestRunner.java:617)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
      at org.testng.SuiteRunner.run(SuiteRunner.java:240)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
      at org.testng.TestNG.run(TestNG.java:1057)
      at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
      Caused by: org.unitils.core.UnitilsException: Unable to create application context for locations [spring-context/eventMessaging-itest-ctx.xml]
      at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:121)
      at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:36)
      at org.unitils.core.util.AnnotatedInstanceManager.getInstanceImpl(AnnotatedInstanceManager.java:234)
      at org.unitils.core.util.AnnotatedInstanceManager.getInstance(AnnotatedInstanceManager.java:121)
      at org.unitils.spring.util.ApplicationContextManager.getApplicationContext(ApplicationContextManager.java:65)
      at org.unitils.spring.SpringModule.getApplicationContext(SpringModule.java:235)
      at org.unitils.spring.SpringModule.getSpringBeanByType(SpringModule.java:185)
      at org.unitils.spring.SpringModule.injectSpringBeansByType(SpringModule.java:363)
      ... 29 more
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'common.messaging.pooledConnectionFactory' defined in class path resource [spring-context/eventMessaging-itest-ctx.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
      at org.unitils.spring.util.ApplicationContextManager.createInstanceForValues(ApplicationContextManager.java:117)
      ... 36 more
      Caused by: java.lang.reflect.MalformedParameterizedTypeException
      at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
      at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:53)
      at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
      at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
      at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
      at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
      at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
      at java.lang.reflect.Method.getGenericParameterTypes(Method.java:291)
      at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
      at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:114)
      at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
      at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
      at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1130)
      at java.beans.Introspector.getBeanInfo(Introspector.java:414)
      at java.beans.Introspector.getBeanInfo(Introspector.java:161)
      at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:220)
      at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144)
      at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252)
      at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:259)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1132)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:992)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
      ... 48 more

        Attachments

          Activity

            People

            • Assignee:
              tim.ducheyne Tim Ducheyne
              Reporter:
              damnhandy Ryan J. McDonough
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: