Spring

From OpenCms Wiki
Revision as of 12:16, 5 December 2006 by Cschoenfeld (Talk | contribs)
Jump to: navigation, search

Here's a forum thread on Spring integration: http://www.opencms-forum.de/opencms-forum/viewthread?thread=1455

Integrating the Spring Framework usually involves definition of a Web Application Context listener-class in web.xml. The Spring Framework already comes with such a listener, org.springframework.web.context.ContextLoaderListener.

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

It starts the Spring ApplicationContext/BeanFactory. It might be required to override the context-pararm contextConfigLocation to tell the listener where it can find the configuration file (the default is /WEB-INF/applicationContext.xml).

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:/application-context.xml</param-value>
  <description>Tells Spring where to find its configuration</description>
</context-param>

Deployment Restriction

Also note that defining a context listener makes it necessary to deploy the Spring JAR in WEB-INF/lib. It is impossible to deploy Spring as part of an OpenCms module because the listener definition prevents the OpenCms Web Application from starting up when the module is first deployed but not yet published (the Spring JARs would not be in WEB-INF/lib yet, but just in the lib folder of your module in the VFS). On Tomcat, if the listener cannot be started there is an error in the catalina.out log file saying

SEVERE: Error listenerStart

Usually, the localhost_log contains more information including a stack trace.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox