按Corda V3.1文档部署Ubuntu服务启动Cordapp时遇Permission denied错误
Hey there, let's work through this permission denied error you're facing when launching your Corda example node (Party B) as a systemd service on Ubuntu. This is a common issue tied to file system permissions or service configuration, so here are the key steps to diagnose and fix it:
1. Verify Node Directory Permissions
First, make sure the user running your Corda service has full read/write access to the node's root directory and all its contents.
- Find your node's directory (e.g.,
/opt/corda/nodes/partyB), then check its current ownership and permissions with:ls -ld /opt/corda/nodes/partyB - If the owner isn't the user your systemd service runs as (let's assume you're using a dedicated
cordauser), fix the ownership recursively:sudo chown -R corda:corda /opt/corda/nodes/partyB - Ensure the user has read, write, and directory execution permissions:
(Thesudo chmod -R u+rwX /opt/corda/nodes/partyBXflag adds execution rights only to directories, not files—this is safer than full777permissions.)
2. Configure Systemd Service to Run as the Correct User
If your systemd service is running as root (the default if not specified), it might clash with permissions set for a regular corda user. Update your service file (typically at /etc/systemd/system/corda-partyB.service):
- Add these lines under the
[Service]section:User=corda Group=corda - Reload systemd to pick up the changes, then restart the service:
sudo systemctl daemon-reload sudo systemctl restart corda-partyB
3. Check Temporary Directory Permissions
Java relies on the /tmp directory for temporary files, and incorrect permissions here can cause the error.
- Verify
/tmphas the correct sticky-bit permissions:
You should see output likels -ld /tmpdrwxrwxrwt—thetat the end is critical. - If not, fix it with:
sudo chmod 1777 /tmp
4. Validate Node Configuration Paths
Double-check your node.conf file for paths that might point to restricted directories:
- Look for settings like
baseDirectory,logPath, or database persistence paths. For example, if logs are configured to write to/var/log/corda, ensure thecordauser owns that directory:sudo mkdir -p /var/log/corda sudo chown corda:corda /var/log/corda
5. Test Manual Node Execution
To confirm the issue is permission-related, switch to the corda user and run the node manually:
su - corda java -jar /opt/corda/corda.jar --config-file /opt/corda/nodes/partyB/node.conf
If you get the same permission error here, it confirms the problem is with the user's access rights rather than systemd-specific configuration.
Most of the time, the root cause is a mismatch between the systemd service's running user and the node directory's ownership. Following these steps should resolve the "Permission denied" error and get your Party B node up and running.
内容的提问来源于stack exchange,提问作者Austin Moothart

