Je reviens sur le problème des modules.

Envoyé par
adiGuba
Il y a pourtant une solution simple : ne pas utiliser le système de module !
Je suis passé sur le JDK 10 il y a quelques mois. Et je lance Geoserver sur mon poste.
1 2 3 4 5 6
| SEVEN@SEVEN-PC MINGW64 /c/Outils/Programmation/geoserver-2.13.2/bin
$ sh startup.sh
GEOSERVER DATA DIR is F:\data\dev-compte-france\geoserver_data_dir
[...]
29 sept. 06:05:48 ERROR [context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'KMLEncoder': Failed to introspect bean class [org.geoserver.kml.KMLEncoder] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException |
D'après les solutions que l'on trouve sur Internet sur ce sujet, il faut rajouter à la ligne de commande la directive :
--add-modules java.xml.bind
Alors, je force le trait exprès pour exagérer mais j'ai fait l'essai et bien sûr ceci ne fonctionne pas :
1 2
| sh startup.sh --add-modules java.xml.bind
sh startup.sh -D--add-modules java.xml.bind |
Il faut lire le contenu du script startup.sh livré par Geotools :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| #!/bin/sh
# -----------------------------------------------------------------------------
# Start Script for GEOSERVER
#
# $Id$
# -----------------------------------------------------------------------------
# Guard against misconfigured JAVA_HOME
if [ ! -z "$JAVA_HOME" -a ! -x "$JAVA_HOME"/bin/java ]; then
echo "The JAVA_HOME environment variable is set but JAVA_HOME/bin/java"
echo "is missing or not executable:"
echo " JAVA_HOME=$JAVA_HOME"
echo "Please either set JAVA_HOME so that the Java runtime is JAVA_HOME/bin/java"
echo "or unset JAVA_HOME to use the Java runtime on the PATH."
exit 1
fi
# Find java from JAVA_HOME or PATH
if [ ! -z "$JAVA_HOME" ]; then
_RUNJAVA="$JAVA_HOME"/bin/java
elif [ ! -z "$(which java)" ]; then
_RUNJAVA=java
else
echo "A Java runtime (java) was not found in JAVA_HOME/bin or on the PATH."
echo "Please either set the JAVA_HOME environment variable so that the Java runtime"
echo "is JAVA_HOME/bin/java or add the Java runtime to the PATH."
exit 1
fi
if [ -z $GEOSERVER_HOME ]; then
#If GEOSERVER_HOME not set then guess a few locations before giving
# up and demanding user set it.
if [ -r start.jar ]; then
echo "GEOSERVER_HOME environment variable not found, using current "
echo "directory. If not set then running this script from other "
echo "directories will not work in the future."
export GEOSERVER_HOME=`pwd`
else
if [ -r ../start.jar ]; then
echo "GEOSERVER_HOME environment variable not found, using current "
echo "location. If not set then running this script from other "
echo "directories will not work in the future."
export GEOSERVER_HOME=`pwd`/..
fi
fi
if [ -z "$GEOSERVER_HOME" ]; then
echo "The GEOSERVER_HOME environment variable is not defined"
echo "This environment variable is needed to run this program"
echo "Please set it to the directory where geoserver was installed"
exit 1
fi
fi
if [ ! -r "$GEOSERVER_HOME"/bin/startup.sh ]; then
echo "The GEOSERVER_HOME environment variable is not defined correctly"
echo "This environment variable is needed to run this program"
exit 1
fi
#Find the configuration directory: GEOSERVER_DATA_DIR
if [ -z $GEOSERVER_DATA_DIR ]; then
if [ -r "$GEOSERVER_HOME"/data_dir ]; then
export GEOSERVER_DATA_DIR="$GEOSERVER_HOME"/data_dir
else
echo "No GEOSERVER_DATA_DIR found, using application defaults"
GEOSERVER_DATA_DIR=""
fi
fi
cd "$GEOSERVER_HOME"
if [ -z $MARLIN_JAR]; then
export MARLIN_JAR=`find \`pwd\`/webapps -name "marlin*.jar" | head -1`
fi
export MARLIN_ENABLER="-Xbootclasspath/a:$MARLIN_JAR -Dsun.java2d.renderer=org.marlin.pisces.MarlinRenderingEngine"
echo "GEOSERVER DATA DIR is $GEOSERVER_DATA_DIR"
#added headless to true by default, if this messes anyone up let the list
#know and we can change it back, but it seems like it won't hurt -ch
exec "$_RUNJAVA" $JAVA_OPTS $MARLIN_ENABLER -DGEOSERVER_DATA_DIR="$GEOSERVER_DATA_DIR" -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar start.jar |
Là, on peut observer qu'en définissant à l'extérieur la variable d'environnement :
export JAVA_OPTS='--add-modules java.xml.bind'
Il démarre correctement.
Donc, c'est résolu pour lui. Mais tous les autres programmes Java démarrant par des scripts se pose le même problème, s'ils ne démarrent pas directement avec un JDK 9+.
Le .sh, ici, il est bien fait. Mais pour les autres que je rencontrerai, s'ils n'ont pas un JAVA_OPTS aussi bien placé : il faudra faire un cycle de lancement et examen des classes manquantes, édition à la main du sh pour rajouter un module, jusqu'à ce que ça marche.
C'est pas si instantané que ça.
Partager