Project

General

Profile

<code class="html">
<div style="font-size:300%; color: #600;">Outdated!</div>

This document is outdated. Please see CdmDataportalDev or CdmServerDev for current documentation.


Webservice Deployment

This HowTo describes all steps necessary to deploy a locally developed version of the webservice and dataportal to the production tomcat server and webserver.

Before taking the steps presented, please make sure everything is working in your local development environment all tests run without errors and that you committed all of your work to the subversion repository.

Updating the dataportal

  1. Connect to the machine that is hosting the drupal instances via ssh.

  2. When logged in to the server, change to the directory the dataportal files reside in and issue a subversion update command.

  3. Also update all themes that have undeployed changes. The themes are likely in the instance folders for the specific dataportals.

Once you have updated the drupal instances, they might not work anymore unless the webservice get updated as well, because new dataportal code might rely on features that are not present in the current webservice.

Updating the database

Changes in the model will definitely come along with changes in the database. Make sure that the model version of your databases match the version of the webservice. Simplest thing to assure that would be a fresh import.

Updating the webservice

BACKUP THE EXISTING WAR FILE ON YOUR TOMCAT MACHINE FIRST, UNLESS YOU ARE 100% SURE OF WHAT YOU ARE DOING!

  1. Adjust the cdm-remote source:trunk/cdmlib/cdmlib-remote/pom.xml.

    1. Make sure you have a settings.xml file in your maven repository (@~/.m2/@), that has at least one entry for the deployment server.
<settings>
    <servers>
        <server>
            <id>ID-OF-TOMCAT-SERVER-TO-DEPLOY-TO</id>
            <username>TOMCAT-USER</username>
            <password>TOMCAT-PASSWORD</password>
        </server>
    </servers>
</settings>
  1. Adjust the tomcat plugin configuration. <url> has to point to the URL of the tomcat server, <servername> has to match the id in settings.xml and we need the <update> switch, so that maven undeploys the old .war file before installing the new one.
...
    <plugin><!--use mvn tomcat:deploy -->
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>tomcat-maven-plugin</artifactId>
        <configuration>
            <update>true</update>
            <server>ID-OF-TOMCAT-SERVER-TO-DEPLOY-TO</server>
            <url>http://YOUR-TOMCAT-SERVER.TLD/manager</url>
        </configuration>
    </plugin>
...
  1. Install all cdmlib projects. Optionally omitting downloads, tests and other output.
mvn install [-q] [-o] [-Dmaven.test.skip]
  1. Generate the .war file and deploy it to the server.
mvn [-Dmaven.test.skip] tomcat:deploy
  1. Since we are using a !UpdatableRoutingDataSource there is no more need to install a service for every portal. You simply need to configure your datasources in an xml file. If not already there, create a hidden folder in CATALINA_HOME (e.g. /usr/share/tomcat5.5@) directory called @.cdmlibrary and create a file datasources.xml
cd /usr/share/tomcat5.5
[mkdir .cdmlibrary]
vi .cdmlibrary/datasources.xml
  1. Enter beans for every datasource. Example configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/tx   http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    ">

    <bean id="default"  lazy-init="true" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
        <property name="username" value="DATABASE-USER"/>
        <property name="password" value="DATABASE-PASSWORD"/>
        <property name="url" value="jdbc:mysql://localhost/DATABASE-NAME"/>
    </bean>

        <bean id="cichorieae"  lazy-init="true" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
        <property name="username" value="DATABASE-USER"/>
        <property name="password" value="DATABASE-PASSWORD"/>
        <property name="url" value="jdbc:mysql://localhost/DATABASE-NAME"/>
    </bean>

    ...
</beans>

The bean with id default is REQUIRED since this is the default datasource used during hibernate initialization.

All other bean ids like cichorieae used in the example above are used as base path per application. If you server for example is intalled at

http://www.myserver.net/cdmserver the content of the cichorieae cdm store is accesible at http://www.myserver.net/cdmserver/cichorieae

A more advanced example setup using an 'A' and a 'B' dataset is found in {TOMCAT-WEBAPPS}/cdmserver/WEB-INF/datasources/example.cdmlibrary/ once the war file is unpacked.

Upon changes to datasources.xml, a management URL has to be called to reload the server settings: http://YOUR-TOMCAT-SERVER.TLD:PORT/cdmserver/manager/dataSources/reload.

And that's basically it!

By now you should have a running instance of your newly deployed webservice. Please check that everything is working correctly.

Caveat

  • In case you deploy quite often, you should restart tomcat from time to time, otherwise you will run into OutOfMemory errors in the PermGen Space, due to reloading of already loaded classes. To do so, login to your server and restart tomcat
/etc/init.d/tomcat restart
  • In case you run into OutOfMemory Exceptions when building the .war file increase the mavens memory within its environment variable.
export MAVEN_OPTS=-Xmx256M

install_all_without_tests.sh View - installs all cdmlib projects but skip tests (580 Bytes) Niels Hoffmann, 08/20/2008 05:09 PM

Add picture from clipboard (Maximum size: 40 MB)