How's that for a specific title?
I just managed to struggle through a problem I was having with Spring MVC on WebLogic 8.1. For some reason, I couldn't reference beans from my application context in my servlet context file. Spring would tell me that it couldn't find the bean that I was referencing.
Here was my setup. I loaded the main Spring ApplicationContext with the ContextLoaderListener. Then I declare a single DispatcherServlet and name it "action". I set the "load-on-startup" value for my servlet to 1 so it gets loaded before everything else.
On Tomcat, this configuration works fine. Spring loads the main application context and then loads the servlet context. I can reference beans defined in applicationContext.xml from action-servlet.xml. No problems.
On WebLogic, I noticed that WebLogic loaded the DispatcherServlet before the ContextLoaderListener was invoked. That meant that the DispatcherServlet's action-servlet.xml was referencing beans that hadn't been instantiated yet! Argh.
I found this article in the Spring support forum. It really didn't have a direct relationship to my problem, but the problem was still the load order of the servlet context versus the application context. I noticed in a code paste that the suggestion was to load the ContextLoaderServlet before the DispatcherServlet. AHA!!! Ditch the listener and try the servlet approach to loading the application context.
SO, I removed the ContextLoaderListener config from my web.xml and used ContextLoaderServlet. I gave it a load-on-startup value of 1 and DispatcherServlet a load-on-startup value of 2. Redeploy, restart... BINGO! We have love.
5/04/2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment