aspose file tools*
The moose likes Other Application Frameworks and the fly likes Spring: Getting web ContextLoaderListener to start without a Servlet... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring: Getting web ContextLoaderListener to start without a Servlet..." Watch "Spring: Getting web ContextLoaderListener to start without a Servlet..." New topic
Author

Spring: Getting web ContextLoaderListener to start without a Servlet...

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
I'm writing a simple Spring/Quartz/Hibernate-based job scheduling system (as a web application), and trying to get the Spring ContextLoaderListener to pick up my context.xml. I don't know much about the whole j2ee lifecycle thing, but when I deploy my WAR file, Tomcat picks it up and explodes it, but the ContextLoaderListener never kicks off (never loads my context.xml file). No exceptions, just... nothing.

Here's the web.xml:


Yeah, that's the WHOLE thing. I'm guessing the listener isn't firing because there's just no context to load. Is that possible? How can I force the listener to fire when my entire application is essntially contained in Spring-Injected beans?

help!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

That is all you need.

But I think this is wrong

<param-value>/WEB-INF/config/context.xml</param-value>

Try to remove the WEB-INF part, because iirc WEB-INF is the location that it is automatically looked at.

For instance, if you were to name the file applicationContext.xml and put it in the WEB-INF folder at its root, then you don't need the <context-param> tags anymore, because applicationContext.xml is the default file name it searches for if you don't put in a <context-param> tag in your web.xml

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Thanks Mark!

I've actually used this exact same config in other projects (where there was a servlet configured), and it worked fine, so I don't think that's it. Check out this Spring Beans Docs. They also mention using the ContextLoaderServlet, guess I could do, although I hear that's been deprecated in favor of ContextLoaderListener...

UPDATE: Yeah, ContextLoaderServlet doesn't exist in Spring 3.0.0M1, so that won't work :-(
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring: Getting web ContextLoaderListener to start without a Servlet...