You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在不停止节点的情况下热更新CorDapp并实现部署与运行解耦?

Great question—this is a super common requirement when working with Corda, especially when you want to keep your network running smoothly while iterating on your CorDapp code. Let’s walk through exactly how to do this:

Step 1: Package Your Updated CorDapp into a Jar

First, you’ll need to build a fresh Jar of your modified CorDapp. The exact command depends on your build tool, but here’s the standard approach for the most common tools:

  • Gradle: Run the following command from your project root. This will build all modules (contracts, workflows, etc.) and output the Jar files in each module’s build/libs directory.

    ./gradlew jar
    

    Pro tip: Make sure your build.gradle files mark Corda core dependencies (like corda-core, corda-node-api) as provided or runtimeOnly—this avoids bundling these into your Jar since the node already has them installed.

  • Maven: Use this command to build and package your CorDapp. The Jars will end up in each module’s target directory.

    mvn clean package
    

    Double-check your pom.xml to exclude Corda core dependencies from the final Jar to keep it lightweight and avoid conflicts.

Step 2: Hot Deploy/Update the CorDapp Without Stopping the Node

Corda (starting from version 4.x) supports hot reloading of CorDapps, so you don’t need to shut down your node. Here’s the step-by-step process:

  1. Locate the node’s Cordapps directory: By default, this is the cordapps folder in your node’s root directory. If you’ve customized your node configuration, check the node.conf file for the cordappsDir setting to find the correct path.

  2. Replace or add the Jar:

    • For an update: Delete the old version of your CorDapp Jar from the cordapps directory, then copy your newly built Jar into it.
    • For a new deployment: Simply copy the new Jar into the cordapps directory.
  3. Trigger the node to reload CorDapps:

    • Using the Node Shell: If you have the node shell open, run this command:
      run reloadCordapps
      
    • Using RPC: If you’re interacting with the node via an RPC client, call the reloadCordapps() method on the NodeRPCConnection instance.
  4. Verify the deployment:

    • Run this command in the node shell to confirm the new CorDapp is loaded (check the version number to ensure it’s the updated one):
      run listCordapps
      
    • Test your updated flows/states/contracts to make sure they work as expected—this will catch any compatibility issues early.
Important Notes to Avoid Issues
  • State Evolution: If you modified the structure of a state, make sure you follow Corda’s state evolution rules (like adding new fields with default values, using @BelongsToContract correctly). Failing to do this can break existing states stored on the node.
  • Contract Updates: Changing contract logic requires extra care—ensure old transactions can still be validated by the new contract, or use contract versioning to maintain backward compatibility.
  • Running Flows: Avoid replacing the Jar while flows that depend on it are still running. Wait for active flows to complete first to prevent runtime errors.
  • Check Logs: After reloading, check the node’s logs (usually in the logs directory) to make sure there are no loading errors or dependency conflicts.

内容的提问来源于stack exchange,提问作者SrikanthVarma A

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:03:32