The container isn't looking in WEB-INF by default during testing, because the resource loader isn't web-aware. You can add the WEB-INF directory to the classpath in the eclipse run configuration, or define a test only applicationContext.xml somewhere in the classpath.
I've run into these types of annoyances myself, and have concluded it's best to restrict defining beans in WEB-INF to those that are web dependent. Any beans that can run outside of a web environment are more portable if loadable from the classpath. On Tue, Mar 17, 2009 at 9:07 AM, Marian <mn...@etai.fr> wrote: > Is it possible to use in an Eclipse configured Appfuse project a straight > Junit > 4 test? A JUNit4 test created in Eclipse with @Test annotations in order to > test > a method? > > When I'm doing that in Eclipse, it throws a "NoSuchBeanDefinitionException"! > I am probably not initialising Spring correctly, however here it is an excerpt > of what I did: > >>>>>>>>>>>>>>>>>>>>>> > String[] path = { > "classpath:/applicationContext-resources.xml", > "classpath:/applicationContext-dao.xml", > "classpath:/applicationContext-service.xml", > "classpath*:/applicationContext.xml", > "/WEB-INF/applicationContext*.xml" > }; > ApplicationContext applicationContext = new > ClassPathXmlApplicationContext(path); > ... > GenericManager requeteManager = applicationContext.getBean ("requeteManager"); >>>>>>>>>>>>>>>>>>>>>> > > The bean "requeteManager" is defined in > src/main/webapp/WEB-INF/applicationContext.xml - and the application works > correctly when started in a web server. > > What did I do wrong? > > Marian > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > For additional commands, e-mail: users-h...@appfuse.dev.java.net > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net For additional commands, e-mail: users-h...@appfuse.dev.java.net