Uploaded image for project: 'Corda'
  1. CORDA-2653

Corda Service needs Thread Context ClassLoader

    Details

    • Type: Bug
    • Status: Done (View workflow)
    • Priority: Medium
    • Resolution: Done
    • Affects versions: Corda 4, Corda Enterprise 4 RC05
    • Fix versions: Corda 4.1
    • Components: None
    • Labels:
      None

      Description

      Running the pigtail sample with Corda 4.0-RC07 resulted in this exception:

      [INFO ] 2019-02-20T14:57:15,306Z [main] corda.BraidServer.apply - starting up braid server for PartyA on port 8080
      [ERROR] 2019-02-20T14:57:15,383Z [main] internal.Node.installCordaServices - Corda service com.template.BootstrapBraidService failed to instantiate. Reason was: io.vertx.core.logging.SLF4JLogDelegateFactory [errorCode=umiifk, moreInformationAt=https://errors.corda.net/OS/4.0-RC07/umiifk]
      java.lang.ExceptionInInitializerError: null
      	at io.vertx.core.impl.VertxImpl.<clinit>(VertxImpl.java:99) ~[?:?]
      	at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:34) ~[?:?]
      	at io.vertx.core.Vertx.vertx(Vertx.java:80) ~[?:?]
      	at io.bluebank.braid.corda.BraidServer.start(BraidServer.kt:63) ~[?:?]
      	at io.bluebank.braid.corda.BraidServer.access$start(BraidServer.kt:28) ~[?:?]
      	at io.bluebank.braid.corda.BraidServer$Companion$bootstrapBraid$1.apply(BraidServer.kt:46) ~[?:?]
      	at io.bluebank.braid.corda.BraidServer$Companion$bootstrapBraid$1.apply(BraidServer.kt:29) ~[?:?]
      	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[?:1.8.0_202]
      	at io.bluebank.braid.corda.BraidServer$Companion.bootstrapBraid(BraidServer.kt:42) ~[?:?]
      	at io.bluebank.braid.corda.BraidConfig.bootstrapBraid(BraidConfig.kt:140) ~[?:?]
      	at io.bluebank.braid.corda.BraidConfig.bootstrapBraid$default(BraidConfig.kt:139) ~[?:?]
      	at com.template.BootstrapBraidService.<init>(BootstrapBraidService.kt:30) ~[?:?]
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_202]
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_202]
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_202]
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_202]
      	at net.corda.node.internal.AbstractNode.installCordaService(AbstractNode.kt:647) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.AbstractNode.installCordaServices(AbstractNode.kt:577) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.AbstractNode.access$installCordaServices(AbstractNode.kt:120) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.AbstractNode$start$7.invoke(AbstractNode.kt:382) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.AbstractNode$start$7.invoke(AbstractNode.kt:120) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.nodeapi.internal.persistence.CordaPersistence.inTopLevelTransaction(CordaPersistence.kt:236) ~[corda-node-api-4.0-RC07.jar:?]
      	at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:221) ~[corda-node-api-4.0-RC07.jar:?]
      	at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:199) ~[corda-node-api-4.0-RC07.jar:?]
      	at net.corda.nodeapi.internal.persistence.CordaPersistence.transaction(CordaPersistence.kt:205) ~[corda-node-api-4.0-RC07.jar:?]
      	at net.corda.node.internal.AbstractNode.start(AbstractNode.kt:371) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.Node.start(Node.kt:419) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartup.startNode(NodeStartup.kt:185) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartupCli$runProgram$2.run(NodeStartup.kt:110) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:162) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartup$initialiseAndRun$5.invoke(NodeStartup.kt:117) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartupLogging$DefaultImpls.attempt(NodeStartup.kt:450) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartup.attempt(NodeStartup.kt:117) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartup.initialiseAndRun(NodeStartup.kt:160) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.node.internal.NodeStartupCli.runProgram(NodeStartup.kt:108) ~[corda-node-4.0-RC07.jar:?]
      	at net.corda.cliutils.CordaCliWrapper.call(CordaCliWrapper.kt:184) ~[corda-tools-cliutils-4.0-RC07.jar:?]
      	at net.corda.cliutils.CordaCliWrapper.call(CordaCliWrapper.kt:152) ~[corda-tools-cliutils-4.0-RC07.jar:?]
      	at picocli.CommandLine.execute(CommandLine.java:1056) ~[picocli-3.8.0.jar:3.8.0]
      	at picocli.CommandLine.access$900(CommandLine.java:142) ~[picocli-3.8.0.jar:3.8.0]
      	at picocli.CommandLine$RunLast.handle(CommandLine.java:1246) ~[picocli-3.8.0.jar:3.8.0]
      	at picocli.CommandLine$RunLast.handle(CommandLine.java:1214) ~[picocli-3.8.0.jar:3.8.0]
      	at picocli.CommandLine$AbstractParseResultHandler.handleParseResult(CommandLine.java:1122) ~[picocli-3.8.0.jar:3.8.0]
      	at picocli.CommandLine.parseWithHandlers(CommandLine.java:1405) ~[picocli-3.8.0.jar:3.8.0]
      	at net.corda.cliutils.CordaCliWrapperKt.start(CordaCliWrapper.kt:72) ~[corda-tools-cliutils-4.0-RC07.jar:?]
      	at net.corda.node.Corda.main(Corda.kt:13) ~[corda-node-4.0-RC07.jar:?]
      Caused by: java.lang.IllegalArgumentException: Error instantiating transformer class "io.vertx.core.logging.SLF4JLogDelegateFactory"
      	at io.vertx.core.logging.LoggerFactory.initialise(LoggerFactory.java:59) ~[?:?]
      	at io.vertx.core.logging.LoggerFactory.<clinit>(LoggerFactory.java:37) ~[?:?]
      	... 45 more
      Caused by: java.lang.ClassNotFoundException: io.vertx.core.logging.SLF4JLogDelegateFactory
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_202]
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_202]
      	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[?:1.8.0_202]
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_202]
      	at io.vertx.core.logging.LoggerFactory.initialise(LoggerFactory.java:56) ~[?:?]
      	at io.vertx.core.logging.LoggerFactory.<clinit>(LoggerFactory.java:37) ~[?:?]
      	... 45 more
      

      The problem code has been fat-jarred into a CorDapp, and the lines in question are:

      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      try {
          Class<?> clz = loader.loadClass(className);
          delegateFactory = (LogDelegateFactory) clz.newInstance();
      } catch (Exception e) {
          throw new IllegalArgumentException("Error instantiating transformer class \"" + className + "\"", e);
      }
      

      The end result is that the Node cannot load the CorDapp.

        Attachments

          Activity

            People

            • Assignee:
              fp Farzad Pezeshkpour
              Reporter:
              chris.rankin Chris Rankin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: