• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

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

 
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!
 
ranger
Posts: 17344
11
Mac IntelliJ IDE 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 :-(
 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!