Results 1 to 2 of 2

Thread: Bug?

  1. #1

    Default Bug?

    I have two bean definition files: datasource_beans.xml and app_beans.xml
    and I place these file names in the web.xml file and start web app
    server, it works fine.

    But, when I place the code in the program for junit testing, I got the
    errors:

    org.springframework.beans.factory.BeanDefinitionSt oreException: Line 68
    in XML document from file
    [C:\devel\webapps\awards\WEB-INF\app_beans.xml] is invalid; nested
    exception is org.xml.sax.SAXParseException: An element with the
    identifier "dataSource" must appear in the document.
    java.lang.NullPointerException
    org.springframework.beans.factory.BeanDefinitionSt oreException: Line 68
    in XML document from file
    [C:\devel\webapps\awards\WEB-INF\app_beans.xml] is invalid; nested
    exception is org.xml.sax.SAXParseException: An element with the
    identifier "dataSource" must appear in the document.

    Here is my code:

    org.springframework.context.ApplicationContext ctx = null;
    String[] paths = {"/WEB-INF/datasource_beans.xml",
    "/WEB-INF/app_beans.xml"};
    ctx = new FileSystemXmlApplicationContext(paths);

    why?

    -Henry

  2. #2
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    I can only think of different XML parsers (or settings) causing the problem.

    The error should be caused by an IDREF (<ref local="dataSource"/>) but both the servlet app as well as the junit test should give the same result IMO.

    Are you using <ref local="dataSource"/> to reference the dataSource. If so, it (the bean) should be available in the same context file as the reference since it's an XML ID/IDREF.

    Alef

Posting Permissions

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