Spring Controller Plugin documentation for the dotCMS Content Management System

This bundle plugin is an example of how to add Spring support to a bundle plugin; createsand registers a simple Spring Controller.

How to create a bundle plugin with Spring support

Let’s review the file organizationon the Spring (com.dotcms.spring)example.

META-INF/MANIFEST.MF: The manifest file is very important for the deployment, it lists the Bundle Name, Version, and Packages.

In this MANIFEST you must specify (see template plugin):

  • Bundle-Name: The name of your bundle
  • Bundle-SymbolicName: A short an unique name for the bundle
  • Bundle-Activator: Package and name of your Activator class (example: com.dotmarketing.osgi.spring.Activator)
  • DynamicImport-Package: *Dynamically adds required imports the plugin may need without adding them explicitly.
  • Import-Package:This is a comma separated list of package's name.List the packages that you are using insidethe bundle plugin and that are exported by dotCMS.


In order to work inside the Apache Felix OSGI runtime, the importand export directive must be bi-directional.

In dotCMS, you must declare the set of packages that will be available to the OSGI plugins by changing the file: dotCMS/WEB-INF/felix/osgi-extra.conf.
This is possible also using the dotCMS UI (System-> Dynamic Plugins -> Exported Packages).

Only after that exported packages are defined in this list,a plugin can import the packages to use them inside the OSGI bundle.


Under the src folder you will find all the Java classes needed to create a new Spring Controller:

$ pwd  
$ ls -l  
-rw-r--r-- 1 Activator.java  
-rw-r--r-- 1 ExampleController.java


Simple annotated Spring Controller. Controllerannotates@ /examplecontroller

@RequestMapping (“/examplecontroller”)

For more information on how dotCMS supports Spring MVC please visit this blog.


Standard Spring configuration file to enable the support for annotation-driven controllers.

Maps the controller to com.dotmarketing.osgi.spring.ExampleController and the view on paths: /application/spring/*.html

In our example, the controller returns “helloworld”, mapping the view to the dotCMS HTMLPage /application/spring/helloworld.html


This bundle activator extends from com.dotmarketing.osgi.GenericBundleActivator and implements BundleActivator.start().

Manually registers the class DispatcherServlet to our spring configuration file (example-servlet.xml).

* PLEASE note the “publishBundleServices( context )” call, this call is MANDATORY (!) as it will allow us to share resourcesbetween the bundle and the host container (dotcms), required to fully integrate Spring with dotCMS.


The Spring controller is registered under the url pattern “/spring” can be tested using the following url's (assuming your dotcms url is localhost:8080):