Mise à jour Tomcat 8 Ubuntu

De EjnTricks
Révision de 1 janvier 2020 à 12:19 par Etienne (discussion | contributions)

(diff) ← Version précédente | Voir la version courante (diff) | Version suivante → (diff)

Sur une installation initiale, la commande suivante est suffisante.

#sudo apt-get install tomcat8


Cet article présente donc la procédure d'installation de Tomcat en version 8 avec une installation déjà présente en version 7.


Hand-icon.png Votre avis

Nobody voted on this yet

 You need to enable JavaScript to vote


System-Install-icon.png Installation

Le paquet tomcat8 est installé.

#sudo apt-get install tomcat8
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
The following additional packages will be installed:
  libtomcat8-java tomcat8-common
Paquets suggérés :
  libtcnative-1 tomcat8-admin tomcat8-docs tomcat8-examples tomcat8-user
Les NOUVEAUX paquets suivants seront installés :
  libtomcat8-java tomcat8 tomcat8-common
0 mis à jour, 3 nouvellement installés, 0 à enlever et 0 non mis à jour.
Il est nécessaire de prendre 4 743 ko dans les archives.
Après cette opération, 5 947 ko d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer ? [O/n] O


Backup-restore.png Migration applications

Les applications étaient installées dans une instance 7 de Tomcat. Suite à l'installation de la version 8, il est nécessaire de déplacer les applications ainsi que leur fichiers de configurations / exécution. Il est préférable d'arrêter l'instance de Tomcat.

#sudo service tomcat7 stop

Puis les applications sont recopiées, attention l'application ROOT est échappée.

#cd /var/lib/tomcat7/webapps
#sudo cp -p -R $(ls /var/lib/tomcat7/webapps | grep -v ROOT) /var/lib/tomcat8/webapps

Le propriétaire est mis à jour pour être affecté à tomcat8. A noter que le propriétaire de l'application ROOT sont modifiées, par défaut c'est affecté à root.

#sudo chown -R tomcat8:tomcat8 /var/lib/tomcat8/webapps/*

Les répertoires de travail sont recopiés en fonction des applications installées. Dans le cadre de cette installation, les commandes suivantes sont exécutées.

#sudo cp -a -p -R /usr/share/tomcat7/.jenkins /usr/share/tomcat8/
#sudo cp -a -p -R /usr/share/tomcat7/.m2 /usr/share/tomcat8/
#sudo cp -a -p -R /usr/share/tomcat7/sonatype-work /usr/share/tomcat8/
#sudo cp -a -p -R /usr/share/tomcat7/subsonic /usr/share/tomcat8/
#sudo cp -a -p -R /usr/share/tomcat7/.subversion /usr/share/tomcat8/

Cela est réalisé au cas par cas, afin de maîtriser les copies nécessaires. De la même manière, le propriétaire est modifié.

#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/.jenkins
#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/.m2
#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/sonatype-work
#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/subsonic
#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/.subversion


Dans le cadre de cette installation, des librairies avaient été rendues disponibles dans le répertoire lib de l'instance précédente, pour diverses applications et sont reprises.

#cd /usr/share/tomcat8/lib
#sudo ln -s ../../java/activation-1.1.jar activation.jar
#sudo ln -s ../../java/mail-1.4.jar mail.jar


Configuration-icon.png Paramétrages

Icon File Owner.png Permissions

Lors de l'installation avec apt-get, les permissions des fichiers peuvent être affectées au compte root. Il peut en résulter des problèmes lors de l'utilisation de produits. Il est donc nécessaire de modifier certains fichiers / répertoires.

#sudo chown tomcat8:tomcat8 /usr/share/tomcat8

Command-icon.png Script démarrage Ubuntu 18.04

le serveur Tomcat est démarré à l'aide de systemd. Le fichier de configuration /lib/systemd/system/tomcat8.service déclare la variable ExecStart pour spécifier le script à exécuter.

#
# Systemd unit file for Apache Tomcat
#

[Unit]
Description=Apache Tomcat 8.5 Web Application Server
Documentation=https://tomcat.apache.org/tomcat-8.5-doc/index.html
After=network.target

[Service]

# Configuration
Environment="CATALINA_HOME=/usr/share/tomcat8"
Environment="CATALINA_BASE=/var/lib/tomcat8"
Environment="CATALINA_TMPDIR=/tmp"
Environment="JAVA_OPTS=-Djava.awt.headless=true"
EnvironmentFile=-/etc/default/tomcat8

# Lifecycle
Type=simple
ExecStartPre=+/usr/libexec/tomcat8/tomcat-update-policy.sh
ExecStart=/bin/sh /usr/libexec/tomcat8/tomcat-start.sh
SuccessExitStatus=143

# Logging
SyslogIdentifier=tomcat8

# Security
User=tomcat8
Group=tomcat8
PrivateTmp=yes
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

Le contenu du script est le suivant et un le script /usr/libexec/tomcat8/tomcat-locate-java.sh est exécuté au démarrage.

#!/bin/sh
#
# Startup script for Apache Tomcat with systemd
#

set -e

# Find the Java runtime and set JAVA_HOME
. /usr/libexec/tomcat8/tomcat-locate-java.sh

# Set the JSP compiler if configured in the /etc/default/tomcat8 file
[ -n "$JSP_COMPILER" ] && JAVA_OPTS="$JAVA_OPTS -Dbuild.compiler=\"$JSP_COMPILER\""

export JAVA_OPTS

# Enable the Java security manager?
SECURITY=""
[ "$TOMCAT_SECURITY" = "yes" ] && SECURITY="-security"


# Start Tomcat
cd $CATALINA_BASE && exec $CATALINA_HOME/bin/catalina.sh run $SECURITY

Et c'est dans ce script, /usr/libexec/tomcat8/tomcat-locate-java.sh, que la recherche de la JVM a été déplacée. Le script est modifié pour indiquer un emplacement prioritaire.

#!/bin/sh
#
# Script looking for a Java runtime suitable for running Tomcat
#
# The script looks for the default JRE/JDK, OpenJDK and Oracle JDK
# as packaged by java-package. The Java runtime found is exported
# in the JAVA_HOME environment variable.
#

set -e

# Find the Java runtime if JAVA_HOME isn't already defined
if [ -z "$JAVA_HOME" ]; then
    # This function sets the variable JDK_DIRS
    find_jdks()
    {
        for java_version in 11 10 9 8
        do
            for jvmdir in /usr/lib/jvm/java-${java_version}-openjdk-* \
                          /usr/lib/jvm/jdk-${java_version}-oracle-* \
                          /usr/lib/jvm/jre-${java_version}-oracle-* \
                          /usr/lib/jvm/java-${java_version}-oracle \
                          /usr/lib/jvm/oracle-java${java_version}-jdk-* \
                          /usr/lib/jvm/oracle-java${java_version}-jre-*
            do
                if [ -d "${jvmdir}" ]
                then
                    JDK_DIRS="${JDK_DIRS} ${jvmdir}"
                fi
            done
        done
    }

    # The first existing directory is used for JAVA_HOME
    JDK_DIRS="/usr/lib/jvm/java-8-oracle /usr/lib/jvm/default-java"
    #JDK_DIRS="/usr/lib/jvm/default-java"
    find_jdks

    # Look for the right JVM to use
    for jdir in $JDK_DIRS; do
        if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
            JAVA_HOME="$jdir"
        fi
    done
    export JAVA_HOME
fi

if [ -z "$JAVA_HOME" ]; then
    echo "<2>No JDK or JRE found - Please set the JAVA_HOME variable or install the default-jdk package"
    exit 1
fi

Il est également possible de modifier le lien default-java pointant par défaut sur l'instance de openjdk.

#ll /usr/lib/jvm
total 108
drwxr-xr-x   6 root root  4096 nov.  26 16:12 ./
drwxr-xr-x 111 root root 69632 nov.  20 12:09 ../
lrwxrwxrwx   1 root root    33 nov.  26 16:10 default-java -> /usr/lib/jvm/java-1.11.0-openjdk-amd64/
lrwxrwxrwx   1 root root    21 avril 21  2018 java-1.11.0-openjdk-amd64 -> java-11-openjdk-amd64/
-rw-r--r--   1 root root  1994 oct.  22 20:46 .java-1.11.0-openjdk-amd64.jinfo
drwxr-xr-x   7 root root  4096 nov.   7 00:15 java-11-openjdk-amd64/
lrwxrwxrwx   1 root root    20 avril 13  2016 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/
-rw-r--r--   1 root root  2600 oct.  22 19:25 .java-1.8.0-openjdk-amd64.jinfo
drwxr-xr-x   8 root root  4096 mai   11  2016 java-7-oracle/
-rw-r--r--   1 root root  2543 mai   11  2016 .java-7-oracle.jinfo
drwxr-xr-x   5 root root  4096 avril 24  2016 java-8-openjdk-amd64/
drwxr-xr-x   8 root root  4096 avril 24  2017 java-8-oracle/
-rw-r--r--   1 root root  2643 avril 24  2017 .java-8-oracle.jinfo

Il est possible de modifier le script ou de changer la définition du lien. Dans le cadre de cette installation, la version 8 de OpenJDK est jugée satisfaisante pour la machine. Le lien est donc modifié.

#sudo rm /usr/lib/jvm/default-java
#sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64 /usr/lib/jvm/default-java

Command-icon.png Script démarrage Ubuntu 12.04

Comme dans le cadre de la mise à jour de Ubuntu 12.04, le script de démarrage de Tomcat doit être modifié s'il est souhaité d'utiliser une JDK Oracle, et non pas OpenJDK. Par défaut, le lien /usr/lib/jvm/default-java est utilisé, pointant sur une instance OpenJDK. Une installation Java 1.8 a été mise en place et est utilisée.

#ll /usr/lib/jvm/
total 100
drwxr-xr-x   5 root root  4096 mai   11 00:20 ./
drwxr-xr-x 109 root root 69632 mai   11 00:20 ../
lrwxrwxrwx   1 root root    24 févr. 25 21:41 default-java -> java-1.8.0-openjdk-amd64/
lrwxrwxrwx   1 root root    20 avril 13 21:33 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64/
-rw-r--r--   1 root root  2600 avril 23 10:26 .java-1.8.0-openjdk-amd64.jinfo
drwxr-xr-x   8 root root  4096 mai   11 00:20 java-7-oracle/
-rw-r--r--   1 root root  2543 mai   11 00:20 .java-7-oracle.jinfo
drwxr-xr-x   5 root root  4096 avril 24 12:38 java-8-openjdk-amd64/
drwxr-xr-x   8 root root  4096 mai   10 17:36 java-8-oracle/
-rw-r--r--   1 root root  2643 mai   10 17:36 .java-8-oracle.jinfo

La modification mise en place spécifie explicitement la version à utiliser, une version 1.8 de Oracle, dans le script /etc/init.d/tomcat8. Cela n'est pas une solution autant paramétrable que le standard, mais convient parfaitement pour les besoins de cette installation.

# this is a work-around until there is a suitable runtime replacement
# for dpkg-architecture for arch:all packages
# this function sets the variable JDK_DIRS
find_jdks()
{
    for java_version in 9 8 7 6
    do
        for jvmdir in /usr/lib/jvm/java-${java_version}-openjdk-* \
                      /usr/lib/jvm/jdk-${java_version}-oracle-* \
                      /usr/lib/jvm/jre-${java_version}-oracle-*
        do
            if [ -d "${jvmdir}" -a "${jvmdir}" != "/usr/lib/jvm/java-${java_version}-openjdk-common" ]
            then
                JDK_DIRS="${JDK_DIRS} ${jvmdir}"
            fi
        done
    done

    # Add older non multi arch installations
    JDK_DIRS="${JDK_DIRS} /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-7-oracle"
}

# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in $DEFAULT)
JDK_DIRS="/usr/lib/jvm/java-8-oracle /usr/lib/jvm/default-java"
# JDK_DIRS="/usr/lib/jvm/default-java"
find_jdks

Le script modifié étant utilisé pour les services, les modifications doivent être pris en compte par le système Systemd. L'ensemble des services est donc rechargé.

#sudo systemctl daemon-reload

Icon-Configuration-Settings.png Variables d'environnement

Dans le cadre de l'installation de Subsonic, un fichier setenv.sh avait été mis en place afin de configurer une variable d'environnement. Ce fichier avait été placé dans le répertoire /var/lib/tomcat7/bin et peut être copié telquel dans la nouvelle instance, soit dans le répertoire /var/lib/tomcat8/bin.

Dans le cadre de cette installation, tout le répertoire est recopié car il ne contenait que ce fichier.

#sudo cp -p -R /var/lib/tomcat7/bin /var/lib/tomcat8

Warning-icon.png Classpath

Sur une machine Ubuntu, les messages d'avertissement suivant étaient présent dans la trace de démarrage de Tomcat.

mai 26, 2016 4:11:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVERTISSEMENT: Problem with directory [/usr/share/tomcat8/common/classes], exists: [false], isDirectory: [false], canRead: [false]
mai 26, 2016 4:11:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVERTISSEMENT: Problem with directory [/usr/share/tomcat8/common], exists: [false], isDirectory: [false], canRead: [false]
mai 26, 2016 4:11:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVERTISSEMENT: Problem with directory [/usr/share/tomcat8/server/classes], exists: [false], isDirectory: [false], canRead: [false]
mai 26, 2016 4:11:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVERTISSEMENT: Problem with directory [/usr/share/tomcat8/server], exists: [false], isDirectory: [false], canRead: [false]
mai 26, 2016 4:11:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVERTISSEMENT: Problem with directory [/usr/share/tomcat8/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
mai 26, 2016 4:11:45 PM org.apache.catalina.startup.ClassLoaderFactory validateFile
AVERTISSEMENT: Problem with directory [/usr/share/tomcat8/shared], exists: [false], isDirectory: [false], canRead: [false]
mai 26, 2016 4:11:48 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server version:        Apache Tomcat/8.0.32 (Ubuntu)

Ceux-ci ne posent aucun problème, il mentionne uniquement un avertissement concernant la configuration des classpaths. Pour rappel, l'instance Tomcat est déployée sous /var/lib/tomcat8, dont le contenu est le suivant.

#ll /var/lib/tomcat8
total 20
drwxr-xr-x  5 root    root    4096 mai   26 15:58 ./
drwxr-xr-x 74 root    root    4096 mai   26 15:01 ../
drwxr-xr-x  2 tomcat7 tomcat7 4096 mai   10 17:39 bin/
lrwxrwxrwx  1 root    root      12 févr. 19 10:11 conf -> /etc/tomcat8/
drwxr-xr-x  2 tomcat8 tomcat8 4096 févr. 19 10:10 lib/
lrwxrwxrwx  1 root    root      17 févr. 19 10:11 logs -> ../../log/tomcat8/
drwxrwxr-x  7 tomcat8 tomcat8 4096 mai   26 15:17 webapps/
lrwxrwxrwx  1 root    root      19 févr. 19 10:11 work -> ../../cache/tomcat8/

A noter le lien conf qui pointe sur le répertoire sous /etc/tomcat8. Celui-ci contient le fichier catalina.properties, dans lequel l'instance est configurée, et notament différents classpaths.

#
#
# List of comma-separated paths defining the contents of the "common"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
# If left as blank,the JVM system loader will be used as Catalina's "common"
# loader.
# Examples:
#     "foo": Add this folder as a class repository
#     "foo/*.jar": Add all the JARs of the specified folder as class
#                  repositories
#     "foo/bar.jar": Add bar.jar as a class repository
#
# Note: Values are enclosed in double quotes ("...") in case either the
#       ${catalina.base} path or the ${catalina.home} path contains a comma.
#       Because double quotes are used for quoting, the double quote character
#       may not appear in a path.
common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar","${catalina.home}/common/classes","${catalina.home}/common/*.jar"

#
# List of comma-separated paths defining the contents of the "server"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
# If left as blank, the "common" loader will be used as Catalina's "server"
# loader.
# Examples:
#     "foo": Add this folder as a class repository
#     "foo/*.jar": Add all the JARs of the specified folder as class
#                  repositories
#     "foo/bar.jar": Add bar.jar as a class repository
#
# Note: Values may be enclosed in double quotes ("...") in case either the
#       ${catalina.base} path or the ${catalina.home} path contains a comma.
#       Because double quotes are used for quoting, the double quote character
#       may not appear in a path.
server.loader=${catalina.home}/server/classes,${catalina.home}/server/*.jar

#
# List of comma-separated paths defining the contents of the "shared"
# classloader. Prefixes should be used to define what is the repository type.
# Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
# the "common" loader will be used as Catalina's "shared" loader.
# Examples:
#     "foo": Add this folder as a class repository
#     "foo/*.jar": Add all the JARs of the specified folder as class
#                  repositories
#     "foo/bar.jar": Add bar.jar as a class repository
# Please note that for single jars, e.g. bar.jar, you need the URL form
# starting with file:.
#
# Note: Values may be enclosed in double quotes ("...") in case either the
#       ${catalina.base} path or the ${catalina.home} path contains a comma.
#       Because double quotes are used for quoting, the double quote character
#       may not appear in a path.
shared.loader=${catalina.home}/shared/classes,${catalina.home}/shared/*.jar

Les répertoires levant une alertes sont donc mentionnés dans les paramètres de configuration.

  • common.loader
  • server.loader
  • shared.loader

Ils sont configurés pour être dans l'arborescence définie par la variable d'environnement catalia.home. Or ceux-ci sont bien présents, mais sous /var/lib/tomcat8, correspond à la variable d'environnement catalina.base.

Par conséquent, deux solutions peuvent être implémentés afin de supprimer les avertissements.

  • Modifier le fichier catalina.properties en spécifiant un chemin correct. Cependant, l'instance ayant été installer avec un paquet, des conflits devront être résolus lors des mises à jour.
  • Créer l'arborescence cible. Cette solution est préférée et est mise en place à l'aide des commandes suivantes.
#sudo mkdir -p /usr/share/tomcat8/common/classes
#sudo mkdir -p /usr/share/tomcat8/server/classes
#sudo mkdir -p /usr/share/tomcat8/shared/classes

Afin d'être homogène avec l'ensemble des fichiers, les permissions sont accordés au compte tomcat7.

#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/common
#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/server
#sudo chown -R tomcat8:tomcat8 /usr/share/tomcat8/shared

Les répertoires sous /var/lib/tomcat8 sont par défaut vides. Il n'y a donc aucun risque de reproduire cette arborescence dans le cadre de cette mise en place.

Icon-log.png Logs Nexus

Un message d'erreur dans la log de Tomcat, soit le fichier /var/log/tomcat8/catalina.out, indique un problème d'accès aux logs pour l'application Nexus.

16:12:12,997 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[logfile] - openFile(/usr/share/tomcat8/sonatype-work/nexus/conf/../logs/nexus.log,true) call failed.
java.io.FileNotFoundException: /usr/share/tomcat8/sonatype-work/nexus/conf/../logs/nexus.log (Permission non accordée)
        at java.io.FileNotFoundException: /usr/share/tomcat8/sonatype-work/nexus/conf/../logs/nexus.log (Permission non accordée)
        at      at java.io.FileOutputStream.open0(Native Method)
        at      at java.io.FileOutputStream.open(FileOutputStream.java:270)
        at      at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
        at      at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:28)
        at      at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:150)
        at      at ch.qos.logback.core.FileAppender.start(FileAppender.java:108)
        at      at ch.qos.logback.core.rolling.RollingFileAppender.start(RollingFileAppender.java:86)
        at      at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
        at      at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
        at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
        at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
        at      at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
        at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:76)
        at      at org.sonatype.nexus.log.internal.LogbackLogManager.reconfigure(LogbackLogManager.java:513)
        at      at org.sonatype.nexus.log.internal.LogbackLogManager.configure(LogbackLogManager.java:172)
        at      at org.sonatype.nexus.webapp.WebappBootstrap.contextInitialized(WebappBootstrap.java:163)
        at      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
        at      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
        at      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at      at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1091)
        at      at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1830)
        at      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at      at java.lang.Thread.run(Thread.java:745)

Les logs ont été externalisées afin de se conformer à l'organisation Ubuntu. Il faut changer les droits d'accès au répertoire et les fichiers déjà existants.

#sudo chown -R tomcat8:tomcat8 /var/log/nexus


Logo-maven.png Configuration Maven

Lors de l'installation de Maven, les permissions sur le dépôt avaient été placées pour le compte tomcat6. Il est donc nécessaire de mettre jour ces permissions.

#sudo chown -R root:tomcat8 /usr/share/maven
#sudo chmod -R 775 /usr/share/maven/repository


Icon-Configuration-Settings.png Configuration subsonic

Un message d'erreur dans la log de Tomcat, soit le fichier /var/log/tomcat8/catalina.out, indique un problème d'accès à la base interne de Subsonic.

[2016-05-26 16:12:02,466] ERROR org.springframework.web.context.ContextLoader - Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mediaFileService' defined in ServletContext resource [/WEB-INF/applicationContext-service.xml]:
Cannot resolve reference to bean 'metaDataParserFactory' while setting bean property 'metaDataParserFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'metaDataParserFactory' defined in ServletContext resource [/WEB-INF/applicationContext-service.xml]: Cannot create inner bean
'net.sourceforge.subsonic.service.metadata.FFmpegParser#2db30afc' of type [net.sourceforge.subsonic.service.metadata.FFmpegParser] while setting bean property 'parsers' with key [1];
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'net.sourceforge.subsonic.service.metadata.FFmpegParser#2db30afc' defined in
ServletContext resource [/WEB-INF/applicationContext-service.xml]: Cannot resolve reference to bean 'transcodingService' while setting bean property 'transcodingService'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transcodingService' defined in ServletContext resource [/WEB-INF/applicationContext-service.xml]:
Cannot resolve reference to bean 'playerService' while setting bean property 'playerService'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'playerService' defined in ServletContext resource [/WEB-INF/applicationContext-service.xml]: Invocation of init method failed; nested exception is
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The database is already in use by another process:
org.hsqldb.persist.NIOLockFile@d07e11a7[file =/usr/share/tomcat7/subsonic/db/subsonic.lck, exists=false, locked=false, valid=false, fl =null]: java.io.FileNotFoundException:
/usr/share/tomcat7/subsonic/db/subsonic.lck (Permission non accordée)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1812)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

Cela est du à la configuration mise en place dans le fichier /var/lib/tomcat8/bin/setenv.sh qui a été complétée lors de l'installation de Subsonic. Le fichier est modifié pour spécifier le nouvel emplacement, soit /usr/share/tomcat8/subsonic.


Delete-file-icon.png Suppression paquet

La précédente version est ensuite désinstallée. La suppression du paquet tomcat7-common entraîne la suppression de l'ensemble des paquets.

#sudo apt-get purge tomcat7-common
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
Les paquets suivants ont été installés automatiquement et ne sont plus nécessaires :
  libservlet3.0-java libtomcat7-java
Veuillez utiliser « sudo apt autoremove » pour les supprimer.
Les paquets suivants seront ENLEVÉS :
  tomcat7* tomcat7-common*
0 mis à jour, 0 nouvellement installés, 2 à enlever et 0 non mis à jour.
Après cette opération, 686 ko d'espace disque seront libérés.
Souhaitez-vous continuer ? [O/n] O

En fin d'exécution des messages avertissent que les fichiers personnalisés, applications / répertoires de travail, ne sont pas supprimés.

dpkg : avertissement : lors de la suppression de tomcat7, le répertoire « /var/lib/tomcat7/webapps » n'était pas vide, donc il n'a pas été supprimé
Suppression de tomcat7-common (7.0.68-1) ...

Comme indiqué lors du démarrage de la suppression, des paquets complémentaires peuvent être supprimés, même si une partie sera réinstallée avec tomcat7.

#sudo apt-get purge libservlet3.0-java libtomcat7-java

Les fichiers résiduels peuvent être supprimés.

#sudo rm -rf /usr/share/tomcat7
#sudo rm -rf /var/lib/tomcat7


Strategy-icon.png Stratégies de Backup

Dans le cadre de cette machine, plusieurs applications ont été mises en place. Des scripts ont été écrits afin de sauvegarder les fichiers / répertoires qui sont parfois dans l'instance de Tomcat. Suite à cette mise à jour, les scripts doivent être repris afin de prendre en compte le nouvel emplacement.

A noter que contrairement à la montée de version 7, l'application Sonar n'est plus impactée car celle-ci est déployé dans son propre serveur d'application depuis la version 4.4.