Geomajas Community Documentation
For servlets, you can use the GeomajasContextListener in the web.xml file.
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Geomajas application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/mypackage/shapeinmem/*.xml</param-value> </context-param> <listener> <listener-class>org.geomajas.dojo.server.servlet.GeomajasContextListener</listener-class> </listener> .....
The "contextConfigLocation" context-param allows you to specify additional application context definition files. These will be included after the built-in Geomajas file and the configuration which is contributed by the available plug-ins. You can include several files by separating them using whitespace. Each location can include the protocol/location used to find the file. When no protocol is specified, the file is searched on the class path. Ant-style wild cards can be used. The following are examples of allowed patterns:
com/mycompany/**/applicationContext.xml file:C:/some/path/*-context.xml classpath:com/mycompany/**/applicationContext.xml classpath*:conf/appContext.xml :/WEB-INF/*-context.xml
The classpath* pattern is specific in that it will combine all the resources that match this exact pattern in the classpath, not just the first one.
When the GeomajasContextListener is used, the application context can be obtained in the servlet using
public void init(ServletConfig config) throws ServletException { ApplicationContext applicationContext = ApplicationContextUtil.getApplicationContext(config); .....
When using another way to define the application context, you have to make sure to include "org/geomajas/spring/geomajasContext.xml" (classpath resource, from the geomajas-impl module), and all the "META-INF/geomajasContext.xml" (classpath resource, configuration for the plug-ins).