Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Philippe Desrosiers
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Philippe Desrosiers
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :-(
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic