diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index e7eadde296..afc8c3c700 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -82,6 +82,10 @@ absolute path to the node's base directory. Currently the defaults in ``/node/src/main/resources/reference.conf`` are as shown in the first example. This is currently the only configuration that has been tested, although in the future full support for other storage layers will be validated. +:h2port: A number that's used to pick the H2 JDBC server port. If not set a randomly chosen port will be used. For production + use you will typically be using a different, non-H2 database backend (e.g. Oracle, SQL Server, Postgres) so this option + is intended primarily for developer mode. + :messagingServerAddress: The address of the ArtemisMQ broker instance. If not provided the node will run one locally. :p2pAddress: The host and port on which the node is available for protocol operations over ArtemisMQ. diff --git a/node/src/main/java/CordaCaplet.java b/node/src/main/java/CordaCaplet.java index 69deb89f1b..0b08285cf9 100644 --- a/node/src/main/java/CordaCaplet.java +++ b/node/src/main/java/CordaCaplet.java @@ -14,8 +14,6 @@ import com.typesafe.config.*; import sun.misc.Signal; -import sun.misc.SignalHandler; - import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; @@ -90,10 +88,12 @@ public class CordaCaplet extends Capsule { if (ATTR_APP_CLASS_PATH == attr) { T cp = super.attribute(attr); - (new File(baseDir, "cordapps")).mkdir(); - // Add additional directories of JARs to the classpath (at the end). e.g. for JDBC drivers + File cordappsDir = new File(baseDir, "cordapps"); + // Create cordapps directory if it doesn't exist. + requireCordappsDirExists(cordappsDir); + // Add additional directories of JARs to the classpath (at the end), e.g., for JDBC drivers. augmentClasspath((List) cp, new File(baseDir, "drivers")); - augmentClasspath((List) cp, new File(baseDir, "cordapps")); + augmentClasspath((List) cp, cordappsDir); try { List jarDirs = nodeConfig.getStringList("jarDirs"); log(LOG_VERBOSE, "Configured JAR directories = " + jarDirs); @@ -139,24 +139,58 @@ public class CordaCaplet extends Capsule { } private void augmentClasspath(List classpath, File dir) { - if (dir.exists()) { - File[] files = dir.listFiles(); - for (File file : files) { + try { + if (dir.exists()) { + // The following might return null if the directory is not there (we check this already) or if an I/O error occurs. + for (File file : dir.listFiles()) { + addToClasspath(classpath, file); + } + } else { + log(LOG_VERBOSE, "Directory to add in Classpath was not found " + dir.getAbsolutePath()); + } + } catch (SecurityException | NullPointerException e) { + log(LOG_QUIET, e); + } + } + + private void requireCordappsDirExists(File dir) { + try { + if (!dir.mkdir() && !dir.exists()) { // It is unlikely to enter this if-branch, but just in case. + logOnFailedCordappDir(); + throw new RuntimeException("Cordapps dir could not be created"); // Let Capsule handle the error (log error, clean up, die). + } + } + catch (SecurityException | NullPointerException e) { + logOnFailedCordappDir(); + throw e; // Let Capsule handle the error (log error, clean up, die). + } + } + + private void logOnFailedCordappDir() { + log(LOG_VERBOSE, "Cordapps dir could not be created"); + } + + private void addToClasspath(List classpath, File file) { + try { + if (file.canRead()) { if (file.isFile() && isJAR(file)) { classpath.add(file.toPath().toAbsolutePath()); + } else if (file.isDirectory()) { // Search in nested folders as well. TODO: check for circular symlinks. + augmentClasspath(classpath, file); } + } else { + log(LOG_VERBOSE, "File or directory to add in Classpath could not be read " + file.getAbsolutePath()); } + } catch (SecurityException | NullPointerException e) { + log(LOG_QUIET, e); } } @Override protected void liftoff() { super.liftoff(); - Signal.handle(new Signal("INT"), new SignalHandler() { - @Override - public void handle(Signal signal) { - // Disable Ctrl-C for this process, so the child process can handle it in the shell instead. - } + Signal.handle(new Signal("INT"), signal -> { + // Disable Ctrl-C for this process, so the child process can handle it in the shell instead. }); } diff --git a/tools/demobench/build.gradle b/tools/demobench/build.gradle index 9d6720c35b..dd36e0a4b5 100644 --- a/tools/demobench/build.gradle +++ b/tools/demobench/build.gradle @@ -9,7 +9,7 @@ */ buildscript { - ext.tornadofx_version = '1.7.10' + ext.tornadofx_version = '1.7.15' ext.jna_version = '4.1.0' ext.purejavacomm_version = '0.0.18' ext.controlsfx_version = '8.40.12' @@ -49,6 +49,15 @@ repositories { } } +configurations.all { + resolutionStrategy { + // Force TornadoFX to use the same version of Kotlin as Corda. + force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + force "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + } +} + dependencies { // TornadoFX: A lightweight Kotlin framework for working with JavaFX UI's. compile "no.tornado:tornadofx:$tornadofx_version"