aspose file tools*
The moose likes Spring and the fly likes Spring configuration file not loaded via the application context but does for the servlet context. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring configuration file not loaded via the application context but does for the servlet context. " Watch "Spring configuration file not loaded via the application context but does for the servlet context. " New topic
Author

Spring configuration file not loaded via the application context but does for the servlet context.

O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Why is it that if i declare a configuration file (my-spring.xml) as shown below the application does not load it.



If i declare it in the MessageDispatcherServlet then it finds it.



Is the first one not the root context? I thought when i declare the config file in the root context then it is available throughout the application but in the above case it seems to be the other way round.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1666
    
    7

What you say is correct it seems like something else is going on. Below is a standard web.xml configuration



As a matter of fact if you wanted to operate with only a root context you could give the dispatcher servlet an empty config location tag like this



[How To Ask Questions][Read before you PM me]
O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Yes that is what i thought. I just dont understand what it is i am doing differently. Here is the complete web.xml file



Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1666
    
    7

I took your web.xml as is and it works fine for me. I defined a couple things in my-spring.xml and everything was picked up fine, I just had empty files for the other contexts you have defined. What is making you say it is not being picked up? Is there an exception in your log?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring configuration file not loaded via the application context but does for the servlet context.