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

#4259 support Java 11 #7514

Merged
merged 14 commits into from Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
91 changes: 91 additions & 0 deletions doc/release-notes/4259-java-11.md
@@ -0,0 +1,91 @@
## Release Highlights

### Java 11

The Dataverse software now runs and requires Java 11. This will provide performance and security enhancements, allows developers to take advantage of new and updated Java features, and moves the project to a platform with better longer term support. This upgrade requires a few extra steps in the release process, outlined below.

## Notes to Admins

### Java 11

There are some things to note and keep in mind regarding the move to Java 11:

- You should install the JDK/JRE following your usual methods, depending on your operating system.
- We targeted and tested Java 11, but 11+ will likely work. Java 11 was targeted because of its long term support.
- You will need to adjust some JVM options in domain.xml as part of the upgrade process. We've provided these steps below.

### New JVM and DB Options

#### New JVM Options

The following JVM Options have been added in support of Java 11:

<jvm-options>[9|]--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.lang=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.net=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.nio=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.util=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/sun.nio.ch=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.management/sun.management=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/sun.net.www.protocol.jrt=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.naming/javax.naming.spi=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.logging/java.util.logging=ALL-UNNAMED</jvm-options>

## Upgrade Instructions

0\. These instructions assume that you've already successfully upgraded from Dataverse 4.x to Dataverse 5 following the instructions in the [Dataverse 5 Release Notes](https://github.com/IQSS/dataverse/releases/tag/v5.0).

1\. Undeploy the previous version.

- `<payara install path>/bin/asadmin list-applications`
- `<payara install path>/bin/asadmin undeploy dataverse<-version>`

(where `<payara install path>` is where Payara 5 is installed, for example: `/usr/local/payara5`)

2\. Stop Payara and remove the generated directory

- `service payara stop`
- remove the generated directory:
`rm -rf <payara install path>/payara/domains/domain1/generated`

3\. In domain.xml:

Remove the following JVM options from the domain><configs><config name-"server-config"><java-config> element::

<jvm-options>-Djava.endorsed.dirs=/usr/local/payara5/glassfish/modules/endorsed:/usr/local/payara5/glassfish/lib/endorsed</jvm-options>
459a448
<jvm-options>-Djava.ext.dirs=${com.sun.aas.javaRoot}/lib/ext${path.separator}${com.sun.aas.javaRoot}/jre/lib/ext${path.separator}${com.sun.aas.instanceRoot}/lib/ext</jvm-options>

Add the following JVM options to the domain><configs><config name-"server-config"><java-config> element:
djbrooke marked this conversation as resolved.
Show resolved Hide resolved

<jvm-options>[9|]--add-opens=java.base/jdk.internal.loader=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.lang=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.net=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.nio=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/java.util=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/sun.nio.ch=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.management/sun.management=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/sun.net.www.protocol.jrt=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.naming/javax.naming.spi=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED</jvm-options>
<jvm-options>[9|]--add-opens=java.logging/java.util.logging=ALL-UNNAMED</jvm-options>

4\. Start Payara

- `service payara start`

5\. Deploy this version.

- `<payara install path>/bin/asadmin deploy dataverse-5.4.war`

6\. Restart payara

- `service payara stop`
- `service payara start`
29 changes: 2 additions & 27 deletions pom.xml
Expand Up @@ -39,11 +39,7 @@
<mockito.version>2.28.2</mockito.version>
<flyway.version>5.2.4</flyway.version>
<jhove.version>1.20.1</jhove.version>
<!--
Jacoco 0.8.2 seems to break Netbeans code coverage integration so we'll use 0.8.1 instead.
See https://github.com/jacoco/jacoco/issues/772 for discussion of how the XML changed.
-->
<jacoco.version>0.8.1</jacoco.version>
<jacoco.version>0.8.6</jacoco.version>
</properties>
<pluginRepositories>
<pluginRepository>
Expand Down Expand Up @@ -816,27 +812,6 @@
<id>all-unit-tests</id>
</profile>
<!-- TODO: Add a profile to run API tests (integration tests that end in IT.java. See conf/docker-aio/run-test-suite.sh -->
<profile>
<id>Java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- for use with `mvn -DcompilerArgument=-Xlint:unchecked compile` -->
<compilerArgument>${compilerArgument}</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Java9Plus</id>
<activation>
Expand All @@ -849,7 +824,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>8</release>
<release>11</release>
<!-- for use with `mvn -DcompilerArgument=-Xlint:unchecked compile` -->
<compilerArgument>${compilerArgument}</compilerArgument>
</configuration>
Expand Down
Expand Up @@ -250,11 +250,12 @@ public Response loadDatasetFields(File file) {
int lineNumber = 0;
HeaderType header = null;
JsonArrayBuilder responseArr = Json.createArrayBuilder();
String[] values = null;
try {
br = new BufferedReader(new FileReader("/" + file));
while ((line = br.readLine()) != null) {
lineNumber++;
String[] values = line.split(splitBy);
values = line.split(splitBy);
if (values[0].startsWith("#")) { // Header row
switch (values[0]) {
case "#metadataBlock":
Expand Down Expand Up @@ -301,7 +302,7 @@ public Response loadDatasetFields(File file) {
return error(Status.EXPECTATION_FAILED, "File not found");

} catch (ArrayIndexOutOfBoundsException e) {
String message = getArrayIndexOutOfBoundMessage(header, lineNumber, e);
String message = getArrayIndexOutOfBoundMessage(header, lineNumber, values.length);
logger.log(Level.WARNING, message, e);
alr.setActionResult(ActionLogRecord.Result.InternalError);
alr.setInfo(alr.getInfo() + "// " + message);
Expand Down Expand Up @@ -352,10 +353,9 @@ public String getGeneralErrorMessage(HeaderType header, int lineNumber, String m
*/
public String getArrayIndexOutOfBoundMessage(HeaderType header,
int lineNumber,
ArrayIndexOutOfBoundsException e) {
int wrongIndex) {

List<String> columns = getColumnsByHeader(header);
int wrongIndex = Integer.parseInt(e.getMessage());

String column = columns.get(wrongIndex - 1);
List<String> arguments = new ArrayList<>();
Expand Down
Expand Up @@ -43,7 +43,7 @@ public void testGeneralErrorMessageBundle() {
@Test
public void testGetArrayIndexOutOfBoundMessage() {
DatasetFieldServiceApi api = new DatasetFieldServiceApi();
String message = api.getArrayIndexOutOfBoundMessage(DatasetFieldServiceApi.HeaderType.DATASETFIELD, 5, new ArrayIndexOutOfBoundsException("4"));
String message = api.getArrayIndexOutOfBoundMessage(DatasetFieldServiceApi.HeaderType.DATASETFIELD, 5, 4);
assertEquals(
"Error parsing metadata block in DATASETFIELD part, line #5: missing 'watermark' column (#5)",
message
Expand Down
Expand Up @@ -62,24 +62,26 @@ public void testGetReadChannel() throws Exception {
@Test
public void testGetDvObject() {
assertEquals(null, instance.getDvObject());
instance.setDvObject(new Dataset());
assertEquals(new Dataset(), instance.getDataset());

try {
Dataset d= new Dataset();
instance.setDvObject(d);
//assertSame uses == rather than the .equals() method which would (currently) be true for any two Datasets
assertSame(d, instance.getDataset()); try {
instance.getDataFile();
fail("This should have thrown");
} catch (ClassCastException ex) {
assertEquals(ex.getMessage(), "edu.harvard.iq.dataverse.Dataset cannot be cast to edu.harvard.iq.dataverse.DataFile");
//Test succeeds
}
try {
instance.getDataverse();
fail("This should have thrown");
} catch (ClassCastException ex) {
assertEquals(ex.getMessage(), "edu.harvard.iq.dataverse.Dataset cannot be cast to edu.harvard.iq.dataverse.Dataverse");
//Test succeeds
}
// null driver defaults to 'file'
assertEquals(new DataFile(), new FileAccessIO<>(new DataFile(), null, null).getDataFile());
assertEquals(new Dataverse(), new FileAccessIO<>(new Dataverse(), null, null).getDataverse());
DataFile f= new DataFile();
Dataverse dv = new Dataverse();
assertSame(f, new FileAccessIO<>(f, null, null).getDataFile());
assertSame(dv, new FileAccessIO<>(dv, null, null).getDataverse());
}

@Test
Expand Down