Corda database connection with SQL Server 17 failed - corda

Facing this error when trying to connect Corda v3.3 to SQL server 2017.
Could not find method dataSourceProperties() for arguments [build_b58g7zpxmgi2o4qynsvg23rrl$_run_closure7$_closure18$_closure22#6e5d745d] on object of type
net.corda.plugins.Node.
deployNodes code snippet is
dataSourceProperties {
dataSourceClassName ("com.microsoft.sqlserver.jdbc.SQLServerDataSource")
dataSource.url ("jdbc:sqlserver://localhost:1433;databaseName=testdb")
dataSource.user (testuser)
dataSource.password (123)
}
database {
transactionIsolationLevel (READ_COMMITTED)
}
jarDirs = [".../Microsoft JDBC Driver 6.2 for SQL Server/sqljdbc_6.2/enu/"]

You are confusing the syntax of deployNodes with the syntax of the node.conf node configuration file.
If you want to add additional configuration options in deployNodes that will be copied to the node's node.conf file, you need to use extraConfig, as follows:
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
node {
name "O=PartyA,L=London,C=GB"
p2pPort 10007
rpcSettings {
address("localhost:10008")
adminAddress("localhost:10048")
}
cordapps = ["$corda_release_group:corda-finance:$corda_release_version"]
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
extraConfig = [
dataSourceProperties: [
dataSourceClassName: 'com.microsoft.sqlserver.jdbc.SQLServerDataSource',
dataSource : [
url : 'jdbc:sqlserver://localhost:1433;databaseName=testdb',
user : 'testuser',
password: '123'
]
],
database : [transactionIsolationLevel: 'READ_COMMITTED'],
jarDirs : ['.../Microsoft JDBC Driver 6.2 for SQL Server/sqljdbc_6.2/enu/']
]
}
}

Related

One corda node is not running

I have developed one sample cordapp. There is a total of 4 nodes(Notary, Dealer, Manufacturer, and HDFC). All the nodes are running successfully apart from the Dealer node. I am getting the below error. I am also sharing the build.gradle file.
error screenshot
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
nodeDefaults {
projectCordapp {
deploy = false
}
cordapp project(':contracts')
cordapp project(':workflows')
}
node {
name "O=Notary,L=London,C=GB"
notary = [validating : false]
p2pPort 10002
rpcSettings {
address("localhost:10003")
adminAddress("localhost:10043")
}
}
node {
name "O=Dealer,L=London,C=GB"
p2pPort 10005
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
node {
name "O=Manufacturer,L=New York,C=US"
p2pPort 10006
rpcSettings {
address("localhost:10009")
adminAddress("localhost:10049")
}
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
node {
name "O=HDFC,L=New York,C=US"
p2pPort 10008
rpcSettings {
address("localhost:10012")
adminAddress("localhost:10052")
}
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
}
You seem to be getting a port binding issue, which means the ports 10046 and 10006 are already in use in your system.
Either change the ports in your node config block in the build.gradle file, or kill the processes running in your port.
Linux
Use below command to find information about process bind to a particular port.
lsof -i :<portNumber>
Use below command to kill the process.
kill <process_id>
Windows
If you are on windows see this SO post to find a kill process on a port: How can you find out which process is listening on a port on Windows?
Always remember to shutdown your nodes properly by typing bye inside each node terminal (including the notary); otherwise you'll run into your current problem (some Java process is still allocating a port that you require for a certain node).
Personally I don't like using runNodes command and its XTerm window; I prefer to do the following:
Browse to a certain node: cd /path-to-project/build/nodes/PartyA
Start the node: java -jar corda.jar
To shutdown the node: bye

How to run corda kotlin example correctly

Problem:
I am trying Corda official documentation hello word application. After Deploying CorDapp I issued
start IOUFlow iouValue: 99, otherParty: "O=PartyB,L=New York,C=US"
This command on Party A. After doing that I tried to check the ledger state by issuing this command on Party A and B.
run vaultQuery contractStateType: com.template.states.IOUState
But it gives the same output as the notary like this.
states: []
statesMetadata: []
totalStatesAvailable: -1
stateTypes: "UNCONSUMED"
otherResults: []
But Output should be like this.
states:
- state:
data:
value: 99
lender: "C=GB,L=London,O=PartyA"
borrower: "C=US,L=New York,O=PartyB"
participants:
- "C=GB,L=London,O=PartyA"
- "C=US,L=New York,O=PartyB"
contract: "com.template.contract.IOUContract"
notary: "C=GB,L=London,O=Notary"
encumbrance: null
constraint:
attachmentId: "F578320232CAB87BB1E919F3E5DB9D81B7346F9D7EA6D9155DC0F7BA8E472552"
ref:
txhash: "5CED068E790A347B0DD1C6BB5B2B463406807F95E080037208627565E6A2103B"
index: 0
statesMetadata:
- ref:
txhash: "5CED068E790A347B0DD1C6BB5B2B463406807F95E080037208627565E6A2103B"
index: 0
contractStateClassName: "com.template.state.IOUState"
recordedTime: 1506415268.875000000
consumedTime: null
status: "UNCONSUMED"
notary: "C=GB,L=London,O=Notary"
lockId: null
lockUpdateTime: 1506415269.548000000
totalStatesAvailable: -1
stateTypes: "UNCONSUMED"
otherResults: []
This is my build.gradle task deployNodes.
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
nodeDefaults {
projectCordapp {
deploy = true
}
cordapp project(':contracts')
cordapp project(':workflows')
}
directory "./build/nodes"
node {
name "O=Notary,L=London,C=GB"
notary = [validating : true]
p2pPort 10002
rpcSettings {
address("localhost:10003")
adminAddress("localhost:10043")
}
}
node {
name "O=PartyA,L=London,C=GB"
p2pPort 10005
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
node {
name "O=PartyB,L=New York,C=US"
p2pPort 10008
rpcSettings {
address("localhost:10009")
adminAddress("localhost:10049")
}
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
}
I tried a lot to find out a solution to this problem on the internet but I was unable to do so as I am a newcomer to Corda. Can someone help me to solve this issue? Thank you very much.
If you didn't get anything on the screen, then the flow didn't complete.
Check the logs of your nodes (inside build/nodes/PartyA/logs).
You can also start the node in debug mode (https://docs.corda.net/node-commandline.html#enabling-remote-debugging) and put breakpoints on your code to see where it's failing.

Corda: Newly added Corda node on a local machine can't be reached by other nodes

I have created a 3 node Corda network on a Linux instance and can initiate and complete flows between the 3 nodes of the network. However when I added a 4th node to the network on the same Linux Instance, any of the nodes in the existing network are unable to complete flows with the 4th node.
Here is the configuration of an existing node:
myLegalName="O=PartyA,L=Mumbai,C=IN"
p2pAddress="198.136.234.245:10005"
rpcSettings {
address="localhost:10006"
adminAddress="localhost:10046"
}
rpcUsers=[
{
password=test
permissions=[
ALL
]
user=user1
}
]
dataSourceProperties = {
dataSourceClassName = "org.postgresql.ds.PGSimpleDataSource"
"dataSource.url" = "jdbc:postgresql://10.0.0.4:5432/postgres"
"dataSource.user" = test2
"dataSource.password" = test2p
}
database = {
transactionIsolationLevel = READ_COMMITTED
schema = test2
}
jarDirs = ['/home/ubuntu/java/postgres']
webAddress="198.136.234.245:10007"
Here is the configuration of a newly added node:
myLegalName="O=PartyB,L=Delhi,C=IN"
p2pAddress="198.136.234.245:10014"
rpcSettings {
address="localhost:10015"
adminAddress="localhost:10055"
}
rpcUsers=[
{
password=test
permissions=[
ALL
]
user=user1
}
]
dataSourceProperties = {
dataSourceClassName = "org.postgresql.ds.PGSimpleDataSource"
"dataSource.url" = "jdbc:postgresql://10.0.0.4:5432/postgres"
"dataSource.user" = test5
"dataSource.password" = test5p
}
database = {
transactionIsolationLevel = READ_COMMITTED
schema = test5
}
jarDirs = ['/home/ubuntu/java/postgres']
webAddress="198.136.234.245:10016"
Here's the message in PartyA's log file:
[INFO ] 2019-07-05T13:27:02,457Z [Node thread-1] flow.[ae2549c0-9bfd-4226-9625-653bc79322b0].initiateSession - Initiating flow session with party O=PartyB, L=Delhi, C=IN. Session id for tracing purposes is SessionId(toLong=5939067804807479907). {}
[INFO ] 2019-07-05T13:27:14,277Z [nioEventLoopGroup-2-4] netty.AMQPClient.operationComplete - Failed to connect to 198.136.234.245:10014 {}
...
[INFO ] 2019-07-05T13:27:15,278Z [nioEventLoopGroup-2-5] netty.AMQPClient.run - Retry connect to 198.136.234.245:10014 {}
deployNodes bootstraps the network. In short, the generated nodes know about each other and nothing else. Adding a new node to the network without running deployNodes will leave the original nodes communicating with each other but they will not see the new node. The new node will also not see the original nodes.
To resolve this, you can rebuild your network using deployNodes.
Or, you will need a network map which will handle the distribution of identities as nodes join the network. An implementation can be found here.

Please register the entity 'net.corda.finance.schemas.CashSchemaV1'

In Corda 3, using Cash with a mock network throws the following error: Please register the entity <ENTITY_NAME>
Am getting an error while accessing the cash-balance api in Obligation cordapp-newrelease-NEW. Which file have to edit inorder to overcome error shown below.
Please register the entity 'net.corda.finance.schemas.CashSchemaV1'
See https://docs.corda.net/api-persistence.html#custom-schema-registration for more information
you need to add the corda-finance module/CorDapp to you node. If you are using deploy nodes use something like the code below
node {
name "O=PartyA,L=London,C=GB"
p2pPort 10002
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
cordapps = [
"$project.group:cordapp-contracts-states:$project.version",
"$project.group:cordapp:$project.version",
"$corda_release_group:corda-finance:$corda_release_version"
]
}

How can I configure security per node in Corda using Gradle?

I want to add the security property to my node configuration using Gradle. I'm trying to do something like the below:
node {
name "O=Bank_A,L=New York,C=US"
p2pPort 10005
rpcSettings {
address("localhost:10006")
adminAddress("localhost:10046")
}
h2Port 9005
cordapps = [
"$project.group:bank-abc:$project.version",
"$project.group:shared-contracts-states:$project.version",
"$corda_release_group:corda-finance:$corda_release_version"
]
security = {
authService = {
dataSource = {
type = "DB"
passwordEncryption = "SHIRO_1_CRYPT"
connection = {
jdbcUrl = "jdbc:h2:tcp://10.0.75.1:9014/node"
username = "some user"
password = "some pass"
driverClassName = "org.h2.Driver"
}
}
}
}
}
when I execute gradlew deployNodes. I get the below error:
What went wrong:
A problem occurred evaluating root project 'tbs-term-reciprocal-dapp'.
Could not set unknown property 'security' for object of type net.corda.plugins.Node.
In order to add security config, you need to use extraConfig within your node's Gradle script.
Taking your example, the extraConfig will look like this:
extraConfig = [
security : [
authService : [
dataSource : [
type: "DB",
passwordEncryption: "SHIRO_1_CRYPT",
connection : [
jdbcUrl: "jdbc:h2:tcp://10.0.75.1:9014/node",
username: "sa",
password: "",
driverClassName: "org.h2.Driver"
]
]
]
]
]

Resources