0
votes

I am trying to run this spring webserver project locally as per https://github.com/corda/samples/tree/release-V4/spring-webserver using command "gradlew.bat runPartyAServer" and getting the following error "2019-08-14 18:08:20,522 main ERROR Rewrite contains an invalid element or attribute "ErrorCodeRewritePolicy" ", can you please help me fix it? PS: The corda-example nodes are already started and running. (edited)

I have already built the corda examples and they are running but spring webserver is not running but producing error

3
Can you share the spring webserver's log output? - devman

3 Answers

0
votes

The reason for the error could be the different versions of dependencies. You can clear the cache and do clean deploy of nodes and run them. Once the nodes have started, start runPartyAServer again.

0
votes

The exception "ERROR Rewrite contains an invalid element or attribute "ErrorCodeRewritePolicy"" is related to version of log4j2.xml.

Most likely, the ErrorCodeRewritePolicy attribute is not present in the version of log4j2.xml file downloaded by the application.

Following is the structure of code containing ErrorCodeRewritePolicy in a log4j2.xml (see https://github.com/corda/corda/blob/master/config/dev/log4j2.xml)-

<Appenders>.....

 <Rewrite name="Console-ErrorCode-Selector">
        <AppenderRef ref="Console-Selector"/>
        <ErrorCodeRewritePolicy/>
    </Rewrite>

    <Rewrite name="Console-ErrorCode-Appender-Println">
        <AppenderRef ref="Console-Appender-Println"/>
        <ErrorCodeRewritePolicy/>
    </Rewrite>.....

Try replacing $log4j_version by "2.7" in the build.gradle. Delete the cache and build folders and allow the gradle to download dependencies again.

Replace -

compile "org.apache.logging.log4j:log4j-web:$log4j_version"

By -

compile "org.apache.logging.log4j:log4j-web:2.7"
0
votes

After alot of debugging, tracing in to the internals of Spring, I think there is a bug in the gradle.build file. I commented out these from the dependencies section:

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
    testCompile "junit:junit:$junit_version"

    // Corda dependencies.
    compile "$corda_release_group:corda-core:$corda_release_version"
    compile "$corda_release_group:corda-rpc:$corda_release_version"
    compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version")  // {
  //      exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
  //  }
  //  compile "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
  //  compile "org.apache.logging.log4j:log4j-web:$log4j_version"
    runtime "$corda_release_group:corda:$corda_release_version"

    // https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-reflect
    compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: '1.3.61'
}

Now my code runs without the annoying ErrorCodeRewritePolicy error messages, AND I can configure the log levels from applications.properties.