I am currently performing testing using the XmlWebApplicationContext() ->
However, I am trying to convert to annotations using :Code:XmlWebApplicationContext ctx = new XmlWebApplicationContext(); ctx.setConfigLocations(new String[]{"trident-resend-servlet.xml", "applicationContext-itest.xml"}); ctx.setServletContext(new MockServletContext("")); ctx.refresh();
@ContextConfiguration(locations={"/trident-resend-servlet.xml", "/applicationContext-itest.xml"})
Dwr requires that I use XmlWebApplicationContext() to perform the spring Dependency injections and i am getting the following error when using @ContextConfiguration...what would be a workaround?
Code:12 May 2010 14:29:28,010 INFO DefaultListableBeanFactory [] Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1342545: defining beans [tridentResendController,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,__dwrConfiguration,dwrController,__AjaxResendManager,resendManager,viewResolver,tridentResendService,endpointLister,resendRequester,resendActionListRequestMapper,resendCriteriaListRequestMapper,jmsTemplate,dataSource,jmsFactory,resendRequestMessageConverter]; root of factory hierarchy 12 May 2010 14:29:28,010 ERROR TestContextManager [] Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@7981d5] to prepare test instance [testGetActiveEndpoints(com.bofa.gcib.gfx.trident.resend.service.DefaultTridentResendServiceITest)] java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:201) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) 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.junit38.AbstractJUnit38SpringContextTests.runBare(AbstractJUnit38SpringContextTests.java:183) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dwrController': Invocation of init method failed; nested exception is java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.directwebremoting.spring.DwrController@18c458] does not run in a WebApplicationContext but in: org.springframework.context.support.GenericApplicationContext@1343ed0: display name [org.springframework.context.support.GenericApplicationContext@1343ed0]; startup date [Wed May 12 14:29:27 CDT 2010]; root of context hierarchy at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) 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:222) 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:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84) at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:42) at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:173) at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:197) ... 16 more Caused by: java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.directwebremoting.spring.DwrController@18c458] does not run in a WebApplicationContext but in: org.springframework.context.support.GenericApplicationContext@1343ed0: display name [org.springframework.context.support.GenericApplicationContext@1343ed0]; startup date [Wed May 12 14:29:27 CDT 2010]; root of context hierarchy at org.springframework.web.context.support.WebApplicationObjectSupport.getWebApplicationContext(WebApplicationObjectSupport.java:105) at org.springframework.web.context.support.WebApplicationObjectSupport.getServletContext(WebApplicationObjectSupport.java:121) at org.directwebremoting.spring.DwrController.afterPropertiesSet(DwrController.java:157) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) ... 32 more


Reply With Quote
