diff --git a/jams-ca/src/main/java/net/jami/jams/ca/workers/crl/CRLWorker.java b/jams-ca/src/main/java/net/jami/jams/ca/workers/crl/CRLWorker.java index 5dea70100df5627b1f35cf79bcf516caa714e55a..07f55b022eb6f035ea57c4db95d1e89ab61bbbbb 100644 --- a/jams-ca/src/main/java/net/jami/jams/ca/workers/crl/CRLWorker.java +++ b/jams-ca/src/main/java/net/jami/jams/ca/workers/crl/CRLWorker.java @@ -51,6 +51,7 @@ public class CRLWorker extends X509Worker<RevocationRequest> { public CRLWorker(PrivateKey privateKey, X509Certificate certificate) { super(privateKey, certificate); + if(privateKey == null || certificate == null) return; this.setDaemon(true); this.start(); //TODO: The CRL needs to be loaded from memory diff --git a/jams-server/pom.xml b/jams-server/pom.xml index 7d1fef27ce5693786a60ac5ab00c49478e77c18a..b0c670bf2560a16906c7ca78e6f2e0fb4f79a63b 100644 --- a/jams-server/pom.xml +++ b/jams-server/pom.xml @@ -38,6 +38,12 @@ <version>${revision}</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>net.jami</groupId> + <artifactId>jams-common</artifactId> + <version>${revision}</version> + <scope>compile</scope> + </dependency> <dependency> <groupId>net.jami</groupId> <artifactId>jami-nameserver</artifactId> diff --git a/jams-server/src/main/java/net/jami/jams/server/Server.java b/jams-server/src/main/java/net/jami/jams/server/Server.java index 536f915d9de8503fe9628eabff4c31edb9de5b37..37665303e47f7ece7bbde5ec4e4e045a7c06ad65 100644 --- a/jams-server/src/main/java/net/jami/jams/server/Server.java +++ b/jams-server/src/main/java/net/jami/jams/server/Server.java @@ -54,10 +54,6 @@ public class Server { public final static AtomicBoolean isInstalled = new AtomicBoolean(false); public final static AtomicBoolean activated = new AtomicBoolean(false); - static { - JsoniterRegistry.initCodecs(); - } - public static DataStore dataStore; //This one gets loaded via JAR, to make it more flexible. public static CertificateAuthority certificateAuthority; @@ -69,7 +65,7 @@ public class Server { public Server(AppUpdater appUpdater, String port, String serverCertificate, String serverPrivateKey) { Server.appUpdater = appUpdater; - + JsoniterRegistry.initCodecs(); String[] args = {port, serverCertificate, serverPrivateKey}; if ((args.length > 0)) main(args); diff --git a/jams-server/src/main/java/net/jami/jams/server/core/TomcatLauncher.java b/jams-server/src/main/java/net/jami/jams/server/core/TomcatLauncher.java index 19b08ea0de0869d2b5d30690e04de3ff2016e3ab..04b4c675c3e3e20869a04930cc20b38aad6ca95b 100644 --- a/jams-server/src/main/java/net/jami/jams/server/core/TomcatLauncher.java +++ b/jams-server/src/main/java/net/jami/jams/server/core/TomcatLauncher.java @@ -51,9 +51,7 @@ import static net.jami.jams.server.Server.certificateAuthority; @Slf4j public class TomcatLauncher { - private final Tomcat tomcat = new Tomcat(); - private Connector connector; - private StandardContext context; + private Tomcat tomcat = new Tomcat(); public TomcatLauncher(int port) { tomcat.getService().addConnector(TomcatConnectorFactory.getNoSSLConnector(port)); @@ -72,7 +70,7 @@ public class TomcatLauncher { log.info("Found a valid trust store, injecting into tomcat!"); tomcat.getService().addConnector(TomcatConnectorFactory.getSSLConnectorWithTrustStore(certificateFile, keyFile, port)); } else { - connector = TomcatConnectorFactory.getSSLConnectorWithoutTrustStore(certificateFile, keyFile, port); + Connector connector = TomcatConnectorFactory.getSSLConnectorWithoutTrustStore(certificateFile, keyFile, port); tomcat.getService().addConnector(connector); } this.startServer(); @@ -81,7 +79,7 @@ public class TomcatLauncher { public void startServer() { String jarName = System.getProperty("user.dir") + File.separator + "jams-server.jar"; log.info("JAR Resource File = " + jarName); - context = (StandardContext) tomcat.addWebapp("", new File(System.getProperty("user.dir")).getAbsolutePath()); + StandardContext context = (StandardContext) tomcat.addWebapp("", new File(System.getProperty("user.dir")).getAbsolutePath()); context.getJarScanner().setJarScanFilter((jarScanType, s) -> false); log.info("Serving application from: " + new File(System.getProperty("user.dir")).getAbsolutePath()); @@ -126,6 +124,7 @@ public class TomcatLauncher { certificateAuthority.shutdownThreads(); tomcat.stop(); tomcat.destroy(); + tomcat = null; } } catch (Exception e) { log.info("Failed to stop tomcat server with error {}", e.getMessage());