Je n’arrive plus à compiler avec maven
le projet Asqatasun et le plugin Jenkins
suite à la mise à jour de l’OS d’un ordinateur (de Ubuntu 14.04 à Ubuntu 16.04).
Avant cette mise à jour, les paquets maven
et openjdk-7-jdk
étaient installés à partir des dépôts officiels. Après la mise à jour, la compilation n’est plus possible. Pour Ubuntu 16.06, le paquet openjdk-7-jdk
n’est plus disponible et c’est openjdk-8-jdk
qui le remplace.
Log pour le plugin Jenkins
Warning: JAVA_HOME environment variable is not set. [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Asqatasun Jenkins Plugin 1.3 [INFO] ------------------------------------------------------------------------ [WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2 [INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ asqatasun --- [INFO] Deleting (...)/git.Asqatasun-Jenkins-Plugin/target [INFO] [INFO] --- maven-hpi-plugin:1.90:validate (default-validate) @ asqatasun --- [INFO] [INFO] --- maven-enforcer-plugin:1.0.1:enforce (enforce-maven) @ asqatasun --- [INFO] [INFO] --- maven-enforcer-plugin:1.0.1:display-info (display-info) @ asqatasun --- [INFO] Maven Version: 3.3.9 [INFO] JDK Version: 1.8.0_91 normalized as: 1.8.0-91 [INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 4.4.0-31-generic [INFO] [INFO] --- maven-localizer-plugin:1.14:generate (default) @ asqatasun --- [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ asqatasun --- [debug] execute contextualize [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 16 resources [INFO] [INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ asqatasun --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 6 source files to (...)/git.Asqatasun-Jenkins-Plugin/target/classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5:compile (default-compile) on project asqatasun: Fatal error compiling: tools.jar not found: /usr/lib/jvm/java-8-openjdk-amd64/jre/../lib/tools.jar -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
log pour le projet Asqatasun
Warning: JAVA_HOME environment variable is not set. [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: [INFO] [INFO] asqatasun [INFO] engine (...) [INFO] asqatasun-runner [INFO] (...) [INFO] ------------------------------------------------------------------------ [INFO] Building commons-entity 4.1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ asqatasun-commons-entity --- [INFO] Deleting (...)/git.asqatasun.build/engine/commons-entity/target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ asqatasun-commons-entity --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory (...)/git.asqatasun.build/engine/commons-entity/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ asqatasun-commons-entity --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 14 source files to (...)/git.asqatasun.build/engine/commons-entity/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] asqatasun .......................................... SUCCESS [ 0.179 s] [INFO] engine ............................................. SUCCESS [ 0.004 s] [INFO] commons-entity ..................................... FAILURE [ 0.219 s] [INFO] commons-entity-jpa ................................. SKIPPED (...) [INFO] asqatasun-runner ................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ (...) [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project asqatasun-commons-entity: Compilation failure [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
J’ai réglé l’erreur “JAVA_HOME environment variable is not set”
en utilisant les commandes suivantes :
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ PATH="$PATH:/usr/lib/jvm/java-8-openjdk-amd64/bin" export PATH JAVA_HOME
mais le résultat n’est pas meilleur (je n’ai pas conservé les logs).
A ce stade je ne suis pas sûre que JDK était installé (le JRE oui)
et j’ai oublié de faire un javac -version
(je faisais uniquement un java -version
).
Nouvelle tentative en installant openjdk-7-jdk
à partir du dépôt ppa:openjdk-r/ppa
mais la compilation bloquait pour le sous-projet asqatasun-web-app
Dernière tentative en désinstallant maven
et tous les paquets openjdk-*
puis en installant dans la foulée maven
et openjdk-8-jdk
.
La configuration actuelle de l’environnement est :
sudo lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Release: 16.04 Codename: xenial
sudo java -version openjdk version "1.8.0_91" OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14) OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
sudo javac -version javac 1.8.0_91
sudo update-java-alternatives java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
sudo update-alternatives --config javac Il n'existe qu'une « alternative » dans le groupe de liens javac (qui fournit /usr/bin/javac) : /usr/lib/jvm/java-8-openjdk-amd64/bin/javac ls -l /usr/lib/jvm/ lrwxrwxrwx 1 root root 24 févr. 25 21:41 default-java -> java-1.8.0-openjdk-amd64 lrwxrwxrwx 1 root root 20 juil. 21 07:49 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64 drwxr-xr-x 7 root root 4096 juil. 31 03:49 java-8-openjdk-amd64
mvn -version Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_91, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: fr_FR, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-31-generic", arch: "amd64", family: "unix"
La compilation du plugin Jenkins fonctionne maintenant.
Par contre pour le projet Asqatasun
elle échoue pour le sous-projet asqatasun-engine
.
Une idée ?
Ci-dessous le log maven :
[INFO] ------------------------------------------------------------------------ [INFO] Building asqatasun-engine 4.1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ (...) ------------------------------------------------------- T E S T S ------------------------------------------------------- (...) Running org.asqatasun.service.command.UploadAuditCommandImplTest init LoadContent with 1 file 31-07-2016 05:19:55:841 39 INFO org.asqatasun.service.command.UploadAuditCommandImpl - Loading files content {My File Name=MyFileContent} 31-07-2016 05:19:55:841 39 INFO org.asqatasun.service.command.UploadAuditCommandImpl - {My File Name=MyFileContent} has been loaded
LoadContent with several file 31-07-2016 05:19:55:843 41 INFO org.asqatasun.service.command.UploadAuditCommandImpl - Loading files content {file:///My File Name2=MyFileContent2, file:///My File Name1=MyFileContent1} Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.007 sec <<< FAILURE! - in org.asqatasun.service.command.UploadAuditCommandImplTest testLoadContent2(org.asqatasun.service.command.UploadAuditCommandImplTest) Time elapsed: 0.004 sec <<< ERROR! java.lang.AssertionError: Unexpected method call WebResourceDataService.createSite("file:///My File Name2"): WebResourceDataService.createSite("file:///My File Name1"): expected: 1, actual: 0 WebResourceDataService.createPage("file:///My File Name1"): expected: 1, actual: 0 WebResourceDataService.createPage("file:///My File Name2"): expected: 1, actual: 0 WebResourceDataService.saveOrUpdate(EasyMock for interface org.asqatasun.entity.subject.Site): expected: 2, actual: 0 WebResourceDataService.saveOrUpdate(EasyMock for interface org.asqatasun.entity.subject.Page): expected: 1, actual: 0 WebResourceDataService.saveOrUpdate(EasyMock for interface org.asqatasun.entity.subject.Page): expected: 1, actual: 0 at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:44) at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:85) at com.sun.proxy.$Proxy2.createSite(Unknown Source) at org.asqatasun.service.command.UploadAuditCommandImpl.createWebResources(UploadAuditCommandImpl.java:126) at org.asqatasun.service.command.UploadAuditCommandImpl.loadContent(UploadAuditCommandImpl.java:101) at org.asqatasun.service.command.UploadAuditCommandImplTest.testLoadContent2(UploadAuditCommandImplTest.java:190) (...) [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] asqatasun .......................................... SUCCESS [ 0.165 s] [INFO] engine ............................................. SUCCESS [ 0.003 s] (...) [INFO] scenarioloader ..................................... SUCCESS [ 0.087 s] [INFO] asqatasun-engine ................................... FAILURE [ 7.843 s] [INFO] asqatasun-resources ................................ SKIPPED [INFO] testing-tools ...................................... SKIPPED (...) [INFO] asqatasun-runner ................................... SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------