Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrastructure improvements - Migration to Java 11 from Java 8 #3836

Draft
wants to merge 14 commits into
base: jena4-upgrade
Choose a base branch
from

Conversation

michel-heon
Copy link
Member

@michel-heon michel-heon commented Feb 22, 2023

VIVO GitHub issue 3834: (please link to issue)
see also for vitro vivo-project/Vitro#368

  • Migration to Java 11 from Java 8

What does this pull request do?

This PR modifies the pom files so that VIVO and Vitro are compiled and run with Java 11

What's new?

Replacing
            <configuration>
                <source>JAVA_RELEASE</source>
                <target>JAVA_RELEASE</target>
            </configuration>
by
	    <maven.compiler.release>JAVA_RELEASE</maven.compiler.release> 
in top pom file

Addition in Vitro a code segment that aborts the compilation if the configuration is in Java-8 
(Vitro/api/src/test/java/compilation/IsNotCompatibleWithJava8.java)

Adding an echo mechanism for maven properties

Change project.version to 1.14.1-SNAPSHOT

How should this be tested?

  1. Purge the maven downloaded library directory rm -fr ~/.m2/repository
  2. Install Java 11
  3. Install SOLR and Tomcat according to https://wiki.lyrasis.org/display/VIVODOC113x/Installing+VIVO
  4. Configure runtime.properties and applicationSetup.n3
  5. Extracted VIVO and Vitro concerned by this PR
  6. copy this settings.xml in ./VIVO/installer directory
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
   <profiles>
       <profile>
           <id>defaults</id>
           <properties>
               <app-name>${env.APP_NAME}</app-name>
               <vivo-dir>${env.VIVO_HOME}/home</vivo-dir>
               <tomcat-dir>${env.TOMCAT_HOME}</tomcat-dir>
               <default-theme>${env.VIVO_THEME}</default-theme>
               <maven.compiler.release>${env.JAVA_RELEASE}</maven.compiler.release>
           </properties>
       </profile>
   </profiles>
   <activeProfiles>
       <activeProfile>defaults</activeProfile>
   </activeProfiles>
</settings>
  1. set environment variables indicated in settings.xml
# Example
export APP_NAME=vivo
export VIVO_HOME=/opt/vivo/home
export TOMCAT_HOME=/opt/tomcat
  1. Check incompatibility with Java-8
# Run the following commands
export JAVA_RELEASE=8
cd $VIVO
mvn clean install -DskipTests=false -s installer/settings.xml

Overview of the output
During the execution, it is possible to follow the following trace in the maven logs

[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ vivo-home ---
[INFO] Deleting /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/VIVO/home/target
[INFO] Skipping artifact installation
[INFO] 
[INFO] --- maven-antrun-plugin:3.1.0:run (echo-properties) @ vivo-home ---
[INFO] Executing tasks
[WARNING]      [echo] ###################################################################
[WARNING]      [echo] Displaying value of 'vivo-home' properties
[WARNING]      [echo] ###################################################################
[WARNING]      [echo] [app-name]                   vivo
[WARNING]      [echo] [vivo-dir]                   /opt/vivo/home
[WARNING]      [echo] [tomcat-dir]                 /opt/tomcat
[WARNING]      [echo] [default-theme]              wilma
[WARNING]      [echo] [vitro-version]              1.14.1-SNAPSHOT
[WARNING]      [echo] [vivo-version]               1.14.1-SNAPSHOT
[WARNING]      [echo] [java.vendor.version]        Corretto-11.0.18.10.1
[WARNING]      [echo] [java.version]               11.0.18
[WARNING]      [echo] [java.specification.version] 11
[WARNING]      [echo] [maven.compiler.release]     8
[WARNING]      [echo] ###################################################################
[WARNING]      [echo] ###################################################################
[INFO] Executed tasks
#
# ... and later you will see
#
 [INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  27.057 s (Wall Clock)
[INFO] Finished at: 2023-02-22T19:53:24Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile) on project vitro-api: Compilation failure
[ERROR] GIT/Vitro/api/src/test/java/compilation/IsNotCompatibleWithJava8.java:[14,32] error: cannot find symbol
[ERROR]   symbol:   method isBlank()
[ERROR]   location: variable value of type String

The compilation aborts because the class code is not compatible with Java version 8
7. Validate the VIVO/Vitro compilation with Java 11

# Run the following commands
export JAVA_RELEASE=11
cd $VIVO
mvn clean install -DskipTests=false -s installer/settings.xml

Overview of the output
During the execution, it is possible to follow the following trace in the maven logs

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for VIVO 1.14.1-SNAPSHOT:
[INFO] 
[INFO] Vitro .............................................. SUCCESS [ 27.836 s]
[INFO] Vitro Dependencies ................................. SUCCESS [  0.296 s]
[INFO] Vitro API .......................................... SUCCESS [01:08 min]
[INFO] VIVO ............................................... SUCCESS [ 27.836 s]
[INFO] VIVO API ........................................... SUCCESS [ 24.329 s]
[INFO] Vitro Web App ...................................... SUCCESS [  2.606 s]
[INFO] VIVO Web App ....................................... SUCCESS [  0.877 s]
[INFO] Vitro Home ......................................... SUCCESS [  7.982 s]
[INFO] VIVO Home .......................................... SUCCESS [  1.587 s]
[INFO] Vitro Installer .................................... SUCCESS [  8.613 s]
[INFO] Vitro Install Home ................................. SUCCESS [  0.006 s]
[INFO] Vitro Install Web App .............................. SUCCESS [  2.523 s]
[INFO] VIVO Installer ..................................... SUCCESS [  8.613 s]
[INFO] VIVO Install Home .................................. SUCCESS [  2.053 s]
[INFO] VIVO Install Web App ............................... SUCCESS [  2.519 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:10 min (Wall Clock)
[INFO] Finished at: 2023-02-22T20:09:02Z
[INFO] ------------------------------------------------------------------------
  1. Testing execution in tomcat
    Before starting Tomcat, you can copy the samples data contained in https://github.com/vivo-project/sample-data/tree/main/i18n and copy it to $VIVO_HOME/rdf/abox/filegraph
    then
 start solr
 start tomcat

You can navigate VIVO in your browser http://localhost:8080/vivo

You can validate that VIVO runs in TOMCAT in a Java-11 context with the following command

>head -20 $TOMCAT_HOME/logs/catalina.out
# Response
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Picked up _JAVA_OPTIONS: -Xms1024m -Xmx4048m
OpenJDK 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Listening for transport dt_socket at address: 8000
22-Feb-2023 19:09:29.590 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/8.5.85
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jan 11 2023 00:09:15 UTC
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 8.5.85.0
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            5.15.0-1030-aws
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/vivo-studio/deploy/JDK
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           11.0.18+10-LTS
22-Feb-2023 19:09:29.594 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Amazon.com Inc.
22-Feb-2023 19:09:29.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/vivo-studio/deploy/tomcat
22-Feb-2023 19:09:29.595 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /home/ubuntu/VIVO_LYRSAIS_TEST/00-GIT/vivo-studio/deploy/tomcat
22-Feb-2023 19:09:29.596 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED

etc ...

Interested parties

@chenejac

                <configuration>
                    <source>JAVA_RELEASE</source>
                    <target>JAVA_RELEASE</target>
                </configuration>
by
<maven.compiler.release>JAVA_RELEASE</maven.compiler.release> in top pom
file
@michel-heon michel-heon changed the title Infrastructure improvements Infrastructure improvements - Migration to Java 11 from Java 8 Feb 22, 2023
@chenejac chenejac changed the base branch from infrastructure-improvements to main February 23, 2023 20:34
@chenejac
Copy link
Contributor

@michel-heon why did you change version to 1.14.1-SNAPSHOT? Change of the version is usually done by a script when a new release is published.

@chenejac chenejac requested review from litvinovg and a user February 23, 2023 20:44
@michel-heon
Copy link
Member Author

@chenejac
Because version 1.13.1-SNAPSHOT does not reflect where we are in development and it is often confusing to work on branches that do not correspond to the working version

Copy link
Collaborator

@litvinovg litvinovg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michel-heon please remove VIVO an Vitro version changes from pom files. It is not related to the PR scope and can cause merge conflicts in future.

@michel-heon
Copy link
Member Author

@litvinovg The return to 1.13.1 is done.... but this version corresponds to the previous sprint and is not representative of the evolution of development. This version misalignment may lead to misunderstandings about the evolution of the development.

Copy link
Collaborator

@litvinovg litvinovg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to try it out on some OS where Java 8 was installed by default. I tried Centos 7.
But the response I received after building it with Java 8 was confusing. It wasn't about Java requirement, it was about new dependency on maven-antrun-plugin that is not provided with default (3.0.5) maven version on Centos 7.
[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:3.1.0:run (echo-properties) on project vitro-api: The plugin org.apache.maven.plugins:maven-antrun-plugin:3.1.0 requires Maven version 3.2.5 -> [Help 1]
So I had to install new version manually and finally got error that Java 11 is required.
Adding new dependency (maven-antrun-plugin) at this point doesn't look like good to me as it hides the real problem (Java version requirement).
So I suggest to open an issue about properties display in and discuss it there.
For the issue this ticket should resolve I suggest removing maven-antrun-plugin.

@michel-heon
Copy link
Member Author

@litvinovg , Why do a test on an OS installation based on Java 8 when the basic specification of this issue is to use Java 11 ?

@litvinovg
Copy link
Collaborator

@michel-heon To model what user trying to update VIVO or Vitro to next version would experience.

@michel-heon michel-heon requested review from litvinovg and removed request for a user February 27, 2023 19:09
@michel-heon
Copy link
Member Author

@litvinovg @chenejac The files have been changed as discussed

@litvinovg
Copy link
Collaborator

I don't remember discussion about maven enforcer. I think increasing version of maven enforcer and enforcing maven version is unnecessary.

@ghost ghost linked an issue Feb 28, 2023 that may be closed by this pull request
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I do see a spurious space character on line 74 of installer/pom.xml.

Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michel-heon thanks for this. I have created a suggestion for a correction of indentation. Can you please consider/accept before this is ready for merging.

Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michel-heon can we also move this maven-enforcer-plugin in the follow up PR linked with this issue - #3843

Comment on lines +73 to +74
<version>3.2.1</version>
</plugin>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<version>3.2.1</version>
</plugin>
<version>1.4.1</version>
</plugin>

Copy link
Member Author

@michel-heon michel-heon Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chenejac
I don't think it's a good idea to go back to 1.4.1,
This version 1.4.1 doesn't handle the message presentation very well, which makes it very irrelevant to use this utility.
Moreover, if we go back to 1.4.1 we will also have to change VIVO.

Is it really a blocker to use more up-to-date plug-ins?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely it will impose new dependencies on maven or other components. I wouldn't change maven enforcer version in this PR.

@chenejac chenejac changed the base branch from main to jena4-upgrade March 8, 2023 13:45
@chenejac chenejac marked this pull request as draft June 5, 2024 06:39
@chenejac chenejac added this to the v1.16 milestone Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migration to Java 11 from Java 8
3 participants