使用Spring Web服务器在Corda中实施RPC安全管理时发生异常

时间:2018-07-31 11:23:48

标签: spring spring-boot webserver rpc corda

当我们在node.conf文件中指定RPC安全管理配置时,Spring Web服务器未启动。

Getting error as Unresolved reference: proxy, while running PartyAServer.

以下是我的PartyA节点的服务器配置:-

task runPartyAServer(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    main = 'com.example.server.Server'
    environment "server.port", "10022"
    environment "config.rpc.host", "localhost"
    environment "config.rpc.port", "10006"
}

我可以使用以下节点A配置启动该节点,但是在运行PartyA服务器时遇到错误。

node {
        name "O=PartyA,L=London,C=GB"
        advertisedServices = ["com.example"]
        p2pPort 10005
        rpcPort 10006
        cordapps = ["$corda_release_group:corda-finance:$corda_release_version",
                    "com.example:java-source:$version",
                    "com.example:base:$version"]
    }

以下是我的PartyA节点的node.conf:-

extraAdvertisedServiceIds=[
    "com.example"
]
myLegalName="O=PartyA,L=London,C=GB"
networkMapService {
    address="localhost:10002"
    legalName="O=Controller,L=London,C=GB"
}
p2pAddress="localhost:10005"
rpcAddress="localhost:10006"
rpcUsers=[]
security = {
    authService = {
        dataSource = {
            type = "DB",
            passwordEncryption = "SHIRO_1_CRYPT",
            connection = {
               jdbcUrl = "jdbc:oracle:thin:@172.16.105.21:1521:SFMS"
               username = "abinay"
               password = "abinay"
               driverClassName = "oracle.jdbc.OracleDriver"
            }
        }
        options = {
             cache = {
                expireAfterSecs = 120
                maxEntries = 10000
             }
        }
    }
}

在没有用户名和密码的情况下,如何使用以下代码建立nodeRPCConnection(proxy),

 @PostConstruct
    public void initialiseNodeRPCConnection() {
        NetworkHostAndPort rpcAddress = new NetworkHostAndPort(host,rpcPort);
        CordaRPCClient rpcClient = new CordaRPCClient(rpcAddress);
        rpcConnection = rpcClient.start(username, password);
        proxy = rpcConnection.getProxy();
        staticMap.put("proxy",proxy);
    }

1 个答案:

答案 0 :(得分:0)

这使我感到很可能是oracle连接问题。

我首先编写一些Java代码只是为了确保您可以连接到oracle DB,然后着重于使其在cordapp环境中正常工作。

有一个很好的开发人员示例(在java和kotlin中:https://github.com/corda/samples-java/tree/master/Basic/flow-database-access; https://github.com/corda/samples-kotlin/tree/master/Basic/flow-database-access

祝你好运!