I am struggling with my spring MVC web app. The app itself looks to work correctly. 2 days back i wanted to make some JUnit tests for my classes and i've read sth how to make it with Spring.
So i created my Test Class and i used below annotation to run tests with Spring and to load a proper contexts.
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles(profiles = "test")
@ContextConfiguration(locations = {"classpath:/dispatcher-servlet.xml","classpath:/beans.xml","classpath:/jpaContext.xml"}
and when i try to run this test through maven or just by eclipse, im getting following error:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource' defined in class path resource [dispatcher-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
Can anyone tell me why it happens ? App works correctly without testing and all beans are loaded without any issue.
WHy i have such a problem with tests?
Thanks in advance ! Jan