开发者

Using Spring ContextLoaderListener in JBoss config with default wars

I'm trying to use Spring to configure a web app deployed in JBoss. I've added this to the web.xml:

<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
&l开发者_运维技巧t;/listener>

However, I've based my config on the 'default' JBoss config that includes wars such as jmx-console.war, and now these fail to deploy with the error:

[ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

So how can I tell ContextLoaderListener to ignore this error, or at least bypass these particular wars, while still attempting to process my own wars?


You must have your application context at /WEB-INF/applicationContext.xml. As this is application-specific, it should be configured for your applications, not other applications. That is, don't map the ContextLoaderListener at an application server level.

You CAN setup an alternative location, using:

<context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>
         /WEB-INF/mylocation/spring.xml
     </param-value>
</context-param>

But you can't (and you must not) ignore it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜