Bump jersey from 2.35 to 3.1.1 (closes #55)

Change-Id: I7edf5ee4ce87ee2a7489e1145c357ec9f83e42c6
diff --git a/README.md b/README.md
index 7b6750b..fcc9c05 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@
 
 ## Prerequisites
 
-Java 8 (OpenJDK or Oracle JDK),
+Java 11 (OpenJDK or Oracle JDK),
 [Git](http://git-scm.com/),
 [Maven 3](https://maven.apache.org/).
 Further dependencies are resolved using Maven.
diff --git a/pom.xml b/pom.xml
index 61f6935..a2f7382 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,9 +9,9 @@
   <url>https://korap.ids-mannheim.de/</url>
   
   <properties>
-    <java.version>1.8</java.version>
-    <jetty.version>9.4.54.v20240208</jetty.version>
-    <jersey.version>2.35</jersey.version>
+    <java.version>17</java.version>
+    <jetty.version>11.0.12</jetty.version>
+    <jersey.version>3.0.4</jersey.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
   </properties>
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/Exporter.java b/src/main/java/de/ids_mannheim/korap/plkexport/Exporter.java
index 5c27b85..6a5357e 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/Exporter.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/Exporter.java
@@ -1,7 +1,7 @@
 package de.ids_mannheim.korap.plkexport;
 
 import com.fasterxml.jackson.databind.JsonNode;
-import javax.ws.rs.core.Response.ResponseBuilder;
+import jakarta.ws.rs.core.Response.ResponseBuilder;
 import java.io.IOException;
 import java.io.Writer;
 import org.glassfish.jersey.media.sse.EventOutput;
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/JsonExporter.java b/src/main/java/de/ids_mannheim/korap/plkexport/JsonExporter.java
index ded4068..c4bb60b 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/JsonExporter.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/JsonExporter.java
@@ -1,6 +1,6 @@
 package de.ids_mannheim.korap.plkexport;
 
-import javax.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.MediaType;
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
 import java.io.Writer;
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/MatchAggregator.java b/src/main/java/de/ids_mannheim/korap/plkexport/MatchAggregator.java
index 95c2b2e..480f724 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/MatchAggregator.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/MatchAggregator.java
@@ -18,16 +18,18 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.StreamingOutput;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.ResponseBuilder;
+import jakarta.ws.rs.core.Response.Status;
+import jakarta.ws.rs.core.StreamingOutput;
 
 import org.glassfish.jersey.media.sse.EventOutput;
 import org.glassfish.jersey.media.sse.OutboundEvent;
 
 import static de.ids_mannheim.korap.plkexport.Util.*;
 
+import org.tinylog.Logger;
+
 /**
  * Base class for collecting matches and header information
  * for exporters implementing the Exporter interface.
@@ -561,6 +563,7 @@
             this.evOut.write(eventBuilder.build());
         }
         catch (IOException e) {
+            Logger.error(e);
             return;
         };
     };
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java b/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java
index 3d6e3bc..b12c2fa 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java
@@ -14,6 +14,8 @@
 
 import org.tinylog.Logger;
 
+import jakarta.servlet.Servlet;
+
 /**
  * Server to provide the export web service
  */
@@ -49,7 +51,7 @@
 
 
         ServletContainer servletContainer = new ServletContainer();        
-        ServletHolder servletHolder = new ServletHolder(servletContainer);
+        ServletHolder servletHolder = new ServletHolder((Servlet) servletContainer);
         contextHandler.addServlet(servletHolder, "/*");
         
         servletHolder.setInitOrder(0);
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
index cad662b..093f802 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
@@ -12,25 +12,26 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.Response.Status;
+import jakarta.ws.rs.BadRequestException;
+import jakarta.ws.rs.WebApplicationException;
+import jakarta.ws.rs.FormParam;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.client.Invocation;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.UriBuilder;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.ResponseBuilder;
+import jakarta.ws.rs.core.Response.Status;
 
 import static org.apache.commons.io.FilenameUtils.getExtension;
 
@@ -40,8 +41,8 @@
 import org.glassfish.jersey.media.sse.OutboundEvent;
 import org.glassfish.jersey.media.sse.SseFeature;
 
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.Cookie;
+import jakarta.servlet.http.HttpServletRequest;
 import org.glassfish.jersey.server.ContainerRequest;
 
 import static de.ids_mannheim.korap.plkexport.Util.*;
@@ -450,7 +451,7 @@
         if (eventOutput.isClosed())
             return Response.ok("EventSource closed").build();
 
-        new Thread(
+        Thread t = new Thread(
             new Runnable() {
 
                 @Override
@@ -500,7 +501,7 @@
                             eventBuilder.data("done");
                             eventOutput.write(eventBuilder.build());                        
                             eventOutput.close();
-                        }
+                        }   
 
                         catch (IOException ioClose) {
                             Logger.error(ioClose);
@@ -511,7 +512,9 @@
                     };
                     return;
                 }
-            }).start();      
+            });
+        t.start();      
+//        t.join();
 
         String origin = prop.getProperty("server.origin","*");
         if (servletReq != null) {
@@ -519,7 +522,7 @@
             origin = servletReq.getHeader("Origin");
         };
 
-        return Response.ok(eventOutput, SseFeature.SERVER_SENT_EVENTS_TYPE)
+        return Response.ok(eventOutput, String.valueOf(SseFeature.SERVER_SENT_EVENTS_TYPE))
             .header("Access-Control-Allow-Origin", origin)
             .header("Access-Control-Allow-Credentials", "true")
             .header("Vary","Origin")
diff --git a/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java b/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
index ca0154a..9118228 100644
--- a/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
+++ b/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
@@ -9,9 +9,13 @@
 
 import java.util.Properties;
 
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
 
 public class AssetTest extends JerseyTest {
     
diff --git a/src/test/java/de/ids_mannheim/korap/plkexport/CsvExporterTest.java b/src/test/java/de/ids_mannheim/korap/plkexport/CsvExporterTest.java
index 01f9978..5b25c28 100644
--- a/src/test/java/de/ids_mannheim/korap/plkexport/CsvExporterTest.java
+++ b/src/test/java/de/ids_mannheim/korap/plkexport/CsvExporterTest.java
@@ -5,7 +5,7 @@
 import static org.junit.Assert.assertEquals;
 import org.junit.Test;
 
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
 
 public class CsvExporterTest {
     
diff --git a/src/test/java/de/ids_mannheim/korap/plkexport/JsonExporterTest.java b/src/test/java/de/ids_mannheim/korap/plkexport/JsonExporterTest.java
index fb74a2f..6e21511 100644
--- a/src/test/java/de/ids_mannheim/korap/plkexport/JsonExporterTest.java
+++ b/src/test/java/de/ids_mannheim/korap/plkexport/JsonExporterTest.java
@@ -4,14 +4,18 @@
 import java.io.File;
 import java.io.BufferedReader;
 import java.io.FileReader;
-import javax.ws.rs.core.StreamingOutput;
+import java.io.InputStream;
+
+
+
+import jakarta.ws.rs.core.StreamingOutput;
 
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import org.junit.Test;
 
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
 
 public class JsonExporterTest {
 
diff --git a/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java b/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
index 9d838fd..7945dae 100644
--- a/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
+++ b/src/test/java/de/ids_mannheim/korap/plkexport/RtfExporterTest.java
@@ -8,7 +8,7 @@
 
 import org.junit.Test;
 
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response;
 
 public class RtfExporterTest {
     
diff --git a/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java b/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java
index ceb66e1..a24d5fc 100644
--- a/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/plkexport/ServiceTest.java
@@ -26,21 +26,23 @@
 import java.util.LinkedList;
 import java.util.Properties;
 
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
 
 // SSE testing
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
 import org.glassfish.jersey.media.sse.EventListener;
 import org.glassfish.jersey.media.sse.EventSource;
 import org.glassfish.jersey.media.sse.SseFeature;
 import java.util.concurrent.TimeUnit;
+import jakarta.ws.rs.client.WebTarget;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 import org.glassfish.jersey.server.ResourceConfig;