Skip to content

Commit

Permalink
Merge pull request #528 from tdrwenski/upgrade-spring
Browse files Browse the repository at this point in the history
Upgrade spring from 5 to 6
  • Loading branch information
tdrwenski authored Aug 23, 2024
2 parents 74fdfc3 + d880eef commit e70aeb5
Show file tree
Hide file tree
Showing 127 changed files with 344 additions and 381 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ jobs:
matrix:
java-version: [ 17 ]
java-vendor: [ 'temurin' ]
# test against tomcat 8.5.x and tomcat 9.x
servletcontainer: [ 'tomcat85', 'tomcat9' ]
servletcontainer: [ 'tomcat10' ]
steps:
- uses: actions/checkout@v4
- name: Build and test with Gradle (${{ matrix.java-vendor }} ${{ matrix.java-version }})
Expand Down
6 changes: 3 additions & 3 deletions dap4/d4servlet/src/main/java/dap4/servlet/DapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import dap4.core.dmr.*;
import dap4.core.util.*;
import dap4.dap4lib.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.MalformedURLException;
import java.nio.ByteOrder;
Expand Down
2 changes: 1 addition & 1 deletion dap4/d4servlet/src/main/java/dap4/servlet/DapDSR.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import dap4.dap4lib.DapProtocol;
import dap4.dap4lib.RequestMode;

import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down
4 changes: 2 additions & 2 deletions dap4/d4servlet/src/main/java/dap4/servlet/DapRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import dap4.core.util.*;
import dap4.dap4lib.RequestMode;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URISyntaxException;
Expand Down
4 changes: 2 additions & 2 deletions dap4/d4ts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ dependencies {
implementation 'edu.ucar:dap4'
implementation project(":dap4:d4servlet")

providedCompile "jakarta.servlet:jakarta.servlet-api:${depVersion.javaxServletApi}"
providedCompile "jakarta.servlet:jakarta.servlet-api:${depVersion.jakartaServletApi}"

compileOnly 'org.slf4j:slf4j-api'

runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl'
runtimeOnly 'org.apache.logging.log4j:log4j-web'
runtimeOnly 'org.apache.logging.log4j:log4j-jakarta-web'

compileOnly 'org.slf4j:slf4j-api'
}
Expand Down
6 changes: 3 additions & 3 deletions dap4/d4ts/src/main/java/dap4/d4ts/D4TSServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import dap4.dap4lib.DapLog;
import dap4.servlet.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand Down
4 changes: 2 additions & 2 deletions dap4/d4ts/src/main/java/dap4/d4ts/FrontPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import dap4.dap4lib.DapLog;
import dap4.servlet.DapRequest;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down
10 changes: 5 additions & 5 deletions dap4/d4ts/src/main/java/dap4/d4ts/HttpHeadFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
*/
package dap4.d4ts;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponseWrapper;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
Expand Down
2 changes: 1 addition & 1 deletion docs/userguide/src/site/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ docset_name: userguide
netcdf-java_docset_version: 5.6

# this will appear in various doc pages
tomcat_version: 9.0
tomcat_version: 10.1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Users of OS-provided packages via package management systems for Java and/or Tom
## System Requirements

* OpenJDK Java 17
* Apache Tomcat 8.x or 9.x
* Apache Tomcat 10.x

While there are different distributors of Java and servlet containers, Unidata develops, uses and tests the THREDDS Data Server using _OpenJDK Java_ and the _Apache Tomcat_ servlet container.

Expand Down Expand Up @@ -83,50 +83,50 @@ The following example shows Tomcat installation on a linux system.
The installation is performed as the `root` user.

{% include note.html content="
For installation of Tomcat on Windows, see the [Tomcat Setup Guide](http://tomcat.apache.org/tomcat-8.5-doc/setup.html#Windows){:target='_blank'}.
For installation of Tomcat on Windows, see the [Tomcat Setup Guide](http://tomcat.apache.org/tomcat-10.1-doc/setup.html#Windows){:target='_blank'}.
" %}

1. [Download](http://tomcat.apache.org/download-80.cgi){:target="_blank"} current version of the Tomcat 8.5 servlet container.
1. [Download](https://tomcat.apache.org/download-10.cgi){:target="_blank"} current version of the Tomcat servlet container.

2. Install Tomcat as per the Apache Tomcat [installation instructions](http://tomcat.apache.org/tomcat-8.5-doc/setup.html){:target="_blank"}.
2. Install Tomcat as per the Apache Tomcat [installation instructions](http://tomcat.apache.org/tomcat-10.1-doc/setup.html){:target="_blank"}.

Copy the binary tar.gz file into the installation directory (`/usr/local` in this example):

~~~bash
# pwd
/usr/local

# cp /tmp/apache-tomcat-8.5.34.tar.gz .
# cp /tmp/apache-tomcat-xx.tar.gz .

# ls -l
total 196676
-rw-r--r-- 1 root root 9625824 Oct 24 13:27 apache-tomcat-8.5.34.tar.gz
-rw-r--r-- 1 root root 9625824 Oct 24 13:27 apache-tomcat-xx.tar.gz
drwxr-xr-x 7 root root 4096 Oct 6 07:58 jdk-xx
~~~

Unpack the archive file:

~~~bash
# tar xvfz apache-tomcat-8.5.34.tar.gz
# tar xvfz apache-tomcat-xx.tar.gz
~~~

This will create a Tomcat directory:

~~~bash
# ls -l
total 196680
drwxr-xr-x 9 root root 4096 Oct 24 13:29 apache-tomcat-8.5.34
-rw-r--r-- 1 root root 9625824 Oct 24 13:27 apache-tomcat-8.5.34.tar.gz
drwxr-xr-x 9 root root 4096 Oct 24 13:29 apache-tomcat-xx
-rw-r--r-- 1 root root 9625824 Oct 24 13:27 apache-tomcat-xx.tar.gz
drwxr-xr-x 7 root root 4096 Oct 6 07:58 jdk-xx
~~~

Remove the remaining binary `tar.gz` file when the installation is complete.

~~~bash
# rm apache-tomcat-8.5.34.tar.gz
# rm apache-tomcat-xx.tar.gz
# ls -l
total 187282
drwxr-xr-x 9 root root 4096 Oct 24 13:29 apache-tomcat-8.5.34
drwxr-xr-x 9 root root 4096 Oct 24 13:29 apache-tomcat-xx
drwxr-xr-x 7 root root 4096 Oct 6 07:58 jdk-xx
~~~

Expand All @@ -148,12 +148,12 @@ Windows users can consult the [Microsoft Documentation](https://docs.microsoft.c
# pwd
/usr/local

# ln -s apache-tomcat-8.5.34 tomcat
# ln -s apache-tomcat-xx tomcat
# ln -s jdk-xx jdk
# ls -l
total 196684
drwxr-xr-x 9 root root 4096 Oct 24 13:29 tomcat -> apache-tomcat-8.5.34
drwxr-xr-x 9 root root 4096 Oct 24 13:29 apache-tomcat-8.5.34
drwxr-xr-x 9 root root 4096 Oct 24 13:29 tomcat -> apache-tomcat-xx
drwxr-xr-x 9 root root 4096 Oct 24 13:29 apache-tomcat-xx
lrwxrwxrwx 1 root root 12 Oct 24 13:59 jdk -> jdk-xx
drwxr-xr-x 7 root root 4096 Oct 6 07:58 jdk-xx
~~~
Expand Down
27 changes: 1 addition & 26 deletions gradle/any/gretty.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ repositories {
}

// allow servlet container to be configured by setting a system property
// default to tomcat 8.5.x
def servletContainerName = System.getProperty('tds.test.gretty.container')
if (servletContainerName == null || servletContainerName.isEmpty()) {
servletContainerName = 'tomcat85'
servletContainerName = 'tomcat10'
}

import org.akhikhl.gretty.AppBeforeIntegrationTestTask
Expand All @@ -53,23 +52,6 @@ gretty {
// We want to modify Gretty tasks but they won't be added to the project until after evaluation:
// http://goo.gl/qlFXTD. So, our modifications must also occur after evaluation.
afterEvaluate {
// Change the log directory of all tasks that start a server.
// Due to a bug, the normal instanceof operator won't work here. Nor will tasks.withType().
tasks.matching {
GradleUtils.instanceOf(it, AppStartTask.name)
}.each {
// LauncherConfig is only meant to be retrieved during the execution phase, hence the doFirst{}.
// If we try to grab it during evaluation, we get:
// Error opening zip file or JAR manifest missing :
// build/tmp/expandedArchives/org.jacoco.agent-0.7.7.201606060606.jar_aj7uwwfluzmrbfb6clshgf6du/jacocoagent.jar
it.doFirst {
// tomcatBaseDir is the working directory for embedded tomcat. We want to write our logs there as well.
File tomcatBaseDir = it.launcherConfig.baseDir

// Will be something like: "$projectDir/build/serverBaseDir_tomcat8/logs".
it.logDir = file("$tomcatBaseDir/logs").absolutePath
}
}

// These enable HTTPS authentication, which is needed to access the TDS admin interface.
httpsEnabled = true
Expand Down Expand Up @@ -97,10 +79,3 @@ gretty {
}
}
}

configurations.runtimeClasspath {
// When gretty uses tomcat 9, javax.servlet-api gets added to the runtimeClasspath of the projects
// to which the plugin is applied. This makes sure we exclude it, which keeps it from getting included
// with our war artifacts.
exclude group: 'javax.servlet', module: 'javax.servlet-api'
}
1 change: 1 addition & 0 deletions gradle/any/java-internal.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ java {
// Will apply to "compileJava", "compileTestJava", "compileSourceSetJava", etc.
tasks.withType(JavaCompile).all {
options.encoding = 'UTF-8'
options.compilerArgs.add("-parameters")

// show deprecation details
//options.compilerArgs = ['-Xlint:deprecation']
Expand Down
1 change: 1 addition & 0 deletions gradle/any/properties.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ext {

ext {
jvmArguments = [
'--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED',
'--add-exports', 'java.base/jdk.internal.ref=ALL-UNNAMED',
'--add-exports', 'java.base/sun.nio.ch=ALL-UNNAMED',
'--add-exports', 'jdk.unsupported/sun.misc=ALL-UNNAMED',
Expand Down
10 changes: 6 additions & 4 deletions gradle/any/shared-mvn-coords.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ext {

// plugin version management
buildPlugins = [:]
buildPlugins.gretty = 'org.gretty:gretty:3.0.9'
buildPlugins.gretty = 'org.gretty:gretty:4.1.5'
buildPlugins.shadow = 'gradle.plugin.com.github.johnrengelman:shadow:7.1.2'
buildPlugins.sonarqube = 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0'
buildPlugins.spotless = 'com.diffplug.spotless:spotless-plugin-gradle:4.5.1'
Expand All @@ -25,9 +25,11 @@ ext {
depVersion.jaxen = '1.1.6'
depVersion.netcdfJava = '5.6.1-SNAPSHOT'
// gradle seems to have issues with the compileOnly configuration, so we need to provide the full maven
// coordinates for javax.servlet-api if the gradle plugin in applied. If we don't, we see errors like this:
depVersion.javaxServletApi = '4.0.3'
depVersion.hibernateValidator = '6.2.5.Final'
// coordinates for jakarta.servlet-api if the gradle plugin in applied. If we don't, we see errors like this:
depVersion.jakartaServletApi = '5.0.0'
// Spring 6.x servlet mocks require servlet 6 though it can test 5 code
depVersion.testJakartaServletApi = '6.0.0'
depVersion.hibernateValidator = '7.0.0.Final'
// TODO: figure out way to keep this version in sync with netcdf-java version
// It is included in the netcdf-java-bom (via netcdf-java-platform), but we can't
// reference that version in a gradle build script (see gradle/any/protobuf.gradle)
Expand Down
19 changes: 0 additions & 19 deletions gradle/gretty/log4j2Config.xml

This file was deleted.

14 changes: 0 additions & 14 deletions gradle/gretty/logback.xml

This file was deleted.

4 changes: 2 additions & 2 deletions opendap/dtswar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ dependencies {
implementation 'org.jdom:jdom2'
implementation 'org.slf4j:slf4j-api'

providedCompile "jakarta.servlet:jakarta.servlet-api:${depVersion.javaxServletApi}"
providedCompile "jakarta.servlet:jakarta.servlet-api:${depVersion.jakartaServletApi}"

runtimeOnly 'org.apache.taglibs:taglibs-standard-spec'
runtimeOnly 'org.apache.taglibs:taglibs-standard-impl'


runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl'
runtimeOnly 'org.apache.logging.log4j:log4j-web'
runtimeOnly 'org.apache.logging.log4j:log4j-jakarta-web'
}
16 changes: 8 additions & 8 deletions opendap/dtswar/src/main/java/opendap/dts/DTSServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
import opendap.util.Debug;
import org.apache.http.HttpStatus;
import ucar.nc2.util.EscapeStrings;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.*;
import java.nio.charset.StandardCharsets;
Expand All @@ -73,7 +73,7 @@
* reduce the bulk of this file, many of these methods have been
* in wrapper classes in this package (opendap.servlet).
* <p>
* This code relies on the <code>javax.servlet.ServletConfig</code>
* This code relies on the <code>jakarta.servlet.ServletConfig</code>
* interface (in particular the <code>getInitParameter()</code> method)
* to record detailed configuration information used by
* the servlet and it's children.
Expand Down Expand Up @@ -135,7 +135,7 @@
* types.
* <p>
* <b>Configuration:</b><br>
* The AbstractServlet relies on the javax.servlet.ServletConfig
* The AbstractServlet relies on the jakarta.servlet.ServletConfig
* interface (in particular the getInitParameter() method)
* to retrieve configuration information used by the servlet.
* <b>InitParameters:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.zip.DeflaterOutputStream;
import javax.servlet.*;
import javax.servlet.http.*;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import opendap.dap.*;
import opendap.servers.*;
import opendap.dap.parsers.ParseException;
Expand All @@ -69,7 +69,7 @@
* be where the server specific OPeNDAP server data types are
* used via their associated class factory.
* <p/>
* This code relies on the <code>javax.servlet.ServletConfig</code>
* This code relies on the <code>jakarta.servlet.ServletConfig</code>
* interface (in particular the <code>getInitParameter()</code> method)
* to record detailed configuration information used by
* the servlet and it's children.
Expand Down Expand Up @@ -126,7 +126,7 @@
*/


public abstract class AbstractServlet extends javax.servlet.http.HttpServlet {
public abstract class AbstractServlet extends jakarta.servlet.http.HttpServlet {

//////////////////////////////////////////////////
// Statics
Expand Down
Loading

0 comments on commit e70aeb5

Please sign in to comment.