Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: multiple xml configuration files

  1. #1
    Join Date
    Sep 2004
    Posts
    1

    Default multiple xml configuration files

    Hello,
    Is it possible to use multiple xml configuration files for one context?
    I have a very large config file that I would like to cut in separate parts but i need to make cross references between beans defined in the different parts.

    thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    See Spring Reference Guide section 3.15, "Creating an ApplicationContext from a web application", for details on how to do this in a webapp.

    In a non-webapp situation (eg unit test) you just do this:

    Code:
    private String[] configLocations = {"/appctx-datastore.xml", "/appctx-security-relaxed.xml"};
    new ClassPathXmlApplicationContext(configLocations);

  3. #3
    Join Date
    Sep 2004
    Posts
    20

    Default

    And can we reference beans from one file to another?

  4. #4
    Join Date
    Sep 2004
    Posts
    20

    Default

    I found a post that indicatees that this is doable but when we tried it and we used <ref bean= instead of ref local, but we still got an error from Spring telling us:
    "An element with the identifier "primaryDataSource" must appear in the document."

  5. #5
    Join Date
    Aug 2004
    Posts
    25

    Default

    It definitely works. You can reference beans from one file to another. You need to use "ref bean" instead of "ref local" and I think you also need to give your beans ids instead of names.

  6. #6
    Join Date
    Sep 2004
    Posts
    20

    Default

    I have given the beans ids and not names and the error i am getting is from the XML parser. Perhaps it is the opposite, that i should use names instead of id's? I guess we can try that

  7. #7
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    It definitely works with id's. None of my beans have names and I can reference them from one file to another.
    Chris Harris
    Carlisle, UK

  8. #8
    Join Date
    Sep 2004
    Posts
    20

    Default

    what xml parser are you using?

  9. #9
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    I'm afraid I don't know. I imagine it's whatever comes with jboss. If you can tell me how to find out, I'll be happy to do that.
    Chris Harris
    Carlisle, UK

  10. #10
    Join Date
    Aug 2004
    Posts
    25

    Default

    It sounds like something is set up wrong. If you're using "ref bean" then the XML content handler shouldn't even try to resolve those references -- it should be handled at the next level up, after all of the files have been parsed.

Similar Threads

  1. Replies: 4
    Last Post: Apr 4th, 2012, 12:34 AM
  2. Reusable 'Module' configuration files?
    By zanfolim in forum Architecture
    Replies: 6
    Last Post: Sep 28th, 2006, 06:52 AM
  3. Replies: 7
    Last Post: Jul 26th, 2005, 02:48 PM
  4. Unexpected behaviour with multiple config files
    By rgitzel in forum Container
    Replies: 7
    Last Post: Mar 8th, 2005, 07:11 PM
  5. Replies: 2
    Last Post: Aug 28th, 2004, 04:53 AM

Posting Permissions

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