Results 1 to 2 of 2

Thread: ref bean working in tomcat, not in tests

Hybrid View

  1. #1
    Join Date
    Nov 2004
    Posts
    5

    Default 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
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/spring-config.xml
    /WEB-INF/spring-tiles-config.xml
    /WEB-INF/spring-datasource.xml
    </param-value>
    </context-param>

    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?

    -James

  2. #2
    Join Date
    Nov 2004
    Posts
    5

    Default 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?

    -James

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •