Deploying a module using maven
Deploying an OSGi module on a local server is relatively straightforward. Once you have the generated JAR file (in a Maven project it is generated in the target subdirectory), you can simply deploy it to the
digital-factory-data/modules directory of your Jahia installation. This can be done whether the server is running or not, it will be picked up and deployed by the server. Every resource in the module (provided it deployed without any errors) will be immediately accessible, including any libraries that have been embedded in the package. If you have declared services in your bundle, they will also be available upon deployment.
If you intend to deploy a bundle in a cluster, we currently either recommend you use the built-in Jahia module manager, or that you use the module manager REST API (and associated shell scripts). This will ensure that you properly deploy modules in the right order in the cluster. It is still possible to deploy them through a manual procedure but it is not recommended (and not supported).
Deploying using the Jahia Maven Plugin
During development, you will probably want to deploy and redeploy your module often, so using the
jahia:deploy goal makes this a lot easier to do often. You just need to setup a profile with the location and type of your target server, such as in the following example:
<profile> <id>jahia-8.0-tomcat</id> <properties> <jahia.deploy.targetServerType>tomcat</jahia.deploy.targetServerType> <jahia.deploy.targetServerVersion>8</jahia.deploy.targetServerVersion> <jahia.deploy.targetServerDirectory>/Users/john/java/deployments/jahia-8/apache-tomcat-8.0.33 </jahia.deploy.targetServerDirectory> <jahia.debug.address>socket:hostname=localhost,port=8000</jahia.debug.address> </properties> </profile>
You can then simply compile and deploy your module using the following command line:
mvn clean install jahia:deploy -P jahia-8.0-tomcat
Un-deploying or re-deploying a module
If you are using the Jahia Maven Plugin you can simply redeploy a module from the project using the jahia:deploy goal again. Upon deployment in the digital-factory-data/modules directory, Jahia will automatically undeploy the old version and deploy the new one. Alternatively, you can also use the administration’s manage modules UI to undeploy the module or remove the jar file from digital-factory-data/modules.