M.Amin
M.Amin

Reputation: 21

Loading Spring Context Dynamically at Run-time in a Web Application

I'm converting a standard Java Application that uses Spring Framework into a Web App. This application loads new Spring Context based on run-time parameters, that was done using ClassPathXmlApplicationContext/FileSystemXmlApplicationContext.

So my question is how to do the same in a Web Application given that I already configured my web.xml and added Spring Listeners as below:

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Another Problem, my deployment environment is on Tomcat 5.5 where I'm not able to see any logging during spring context loading to know what's wrong.

Upvotes: 2

Views: 2799

Answers (2)

harschware
harschware

Reputation: 13424

To turn on logging you may need to set it in your log4j.properties file, like so: log4j.logger.org.springframework=DEBUG

You also have to ensure that you are logging to the CONSOLE and not some other stream. If you are then log messages should appear in catalina.out

Upvotes: 1

mR_fr0g
mR_fr0g

Reputation: 8722

If you actually mean to load a configurable context on start up of your weblication you could configure your web.xml with a property placeholder for the context name.

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:${my_context_file}</param-value>
</context-param>

Upvotes: 2

Related Questions