Spring web.xml cant load because of <listener>
When I put these lines:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
my appln can't load at all. When I go to http://localhost:8080/app it's not loaded. But when I remove those lines it loads correctly. I've put the necessary lib containing org.springframework.web.context.ContextLoaderListener
in ./app/WEB-INF/lib.
My setup is Tomcat 5.5. Context-param is set:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:./springC开发者_运维问答ontext.xml</param-value>
</context-param>
No stack trace is shown. Error message is:
03-Nov-2010 10:21:48 INFO HostConfig:863 - Deploying web application archive
wma.war
03-Nov-2010 10:21:49 ERROR StandardContext:4253 - Error listenerStart
03-Nov-2010 10:21:49 ERROR StandardContext:4280 - Context [/wma] startup failed
due to previous errors
Thanks
Will
Your contextConfigLocation
is set to a very peculiar value, classpath:./springContext.xml
. It's really clear what that's supposed to mean. Are you looking for the springContext.xml
file in the root of the classpath? If so, then you should use classpath:springContext.xml`, since classpath resource references are always relative to the root of the classpath.
If that fails, then look at Tomcat's DEBUG-level logs, Spring is quite verbose during start-up at DEBUG level, and it should tell you what's going wrong. It's odd that it's not throwing an exception, though, I'd normally expect it to do so.
It could help if you post the server logs.
I've encountered this problem.
type the code explicitly. sometimes copy pasting results in same text but different char code.
make sure spring library is in build path or deployment assembly. i think contextloaderlistener is in org.springframework.web.context
hope this helps :]
You didn't show stack trace, but if you don't have set context-param where ContextLoaderListener can find xml file, then it probably throws an error:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dispatcher-servlet.xml
</param-value>
</context-param>
If you use ContextLoaderListener, you will actually need to have two xml configuration files, because if you use same, then all beans are loaded twice.
精彩评论