Announcement Announcement Module
No announcement yet.
ref bean working in tomcat, not in tests Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ref bean working in tomcat, not in tests

    I am trying to break out the part of my context.xml that refers to the datasource so I can use different databases for testing and production. When I run within tomcat, everything works fine, but when I run my unit tests, I get a "error creating bean" exception due to "can't find bean 'dataSource'

    Here are some specifics:
    web.xml contains

    versus my programmatic instantiation is:
    String[] paths = {"/WEB-INF/spring-config.xml", "/WEB-INF/spring-datasource-test.xml"};
    ctx = new ClassPathXmlApplicationContext(paths);

    If I call ctx.getBeanDefinitionNames right after this initialization, it DOES include 'dataSource', yet the bean in spring-config.xml can't find it. Any thoughts?


  • #2
    I lied

    I lied; it's not the programmatic, DAO test-suite that's having the problem. It's my struts tests - there's no 'dataSource' bean listed for them for some reason.

    AHA: it's because my web.xml was loading my datasource.xml, but my struts-config.xml wasn't (it should have the datasource.xml listed for the properties under <plug-in className="org.springframework.web.struts.ContextL oaderPlugIn">).

    Anybody have a good idea how to make struts aware of the datasource-test xml when it needs to?