NoSuchMethodError Exception in Corda Project - java

In our Corda project We are using FlowExternalAsyncOperation to interact with an external service. The flows are able to interact with external service when invoked via Corda node cli. We have implemented a standalone rpc client to invoke the flows. We are getting the below error when trying to start the nodes via rpc connection. Below is the stack trace of the error
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at net.corda.client.rpc.internal.RPCClientProxyHandler.createRpcObservableMap(RPCClientProxyHandler.kt:205)
at net.corda.client.rpc.internal.RPCClientProxyHandler.<init>(RPCClientProxyHandler.kt:168)
at net.corda.client.rpc.internal.RPCClientProxyHandler.<init>(RPCClientProxyHandler.kt:108)
at net.corda.client.rpc.internal.RPCClient$start$1.invoke(RPCClient.kt:90)
at net.corda.client.rpc.internal.RPCClient$start$1.invoke(RPCClient.kt:32)
at net.corda.core.internal.InternalUtils.logElapsedTime(InternalUtils.kt:224)
at net.corda.core.internal.InternalUtils.logElapsedTime(InternalUtils.kt:214)
at net.corda.client.rpc.internal.RPCClient.start(RPCClient.kt:72)
at net.corda.client.rpc.CordaRPCClient.start(CordaRPCClient.kt:620)
at net.corda.client.rpc.CordaRPCClient.start(CordaRPCClient.kt:575)
at net.corda.client.rpc.CordaRPCClient.start(CordaRPCClient.kt:529)
at net.corda.client.rpc.CordaRPCClient.start$default(CordaRPCClient.kt:527)
at net.corda.client.rpc.CordaRPCClient.start(CordaRPCClient.kt)

Putting the solution in the answer.
The issue comes mostly due to version mismatch in the dependencies. This case perhaps has two different versions of the same library. One of them can be excluded using gradle.
Example:
compile('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}

Related

kafka streams stop working after upgrade to spring-kafka:2.5.3.RELEASE

I am trying to upgrade my Spring-boot application to version 2.5.0
Once i do the upgrade:
plugins {
id 'org.springframework.boot' version '2.5.0'
}
I get an error saying
Failed to introspect Class
[org.springframework.boot.actuate.autoconfigure.metrics.KafkaMetricsAutoConfiguration$KafkaStreamsMetricsConfiguration]
Checking this class i find that it is indeed broken as "addListener" in the code below cannot be resolved
static class KafkaStreamsMetricsConfiguration {
#Bean
StreamsBuilderFactoryBeanCustomizer kafkaStreamsMetrics(MeterRegistry meterRegistry) {
return (factoryBean) -> factoryBean.addListener(new KafkaStreamsMicrometerListener(meterRegistry));
}
}
The code above is coming from spring-boot-actuator-autoconfigure:2.5.0 jar.
This issue is solved if update my spring-kafka dependency to any version above 2.5.2.RELEASE
for example:
implementation 'org.springframework.kafka:spring-kafka:2.5.3.RELEASE'
"addListener" is now taken from StreamsBuilderFactoryBean under the spring-kafka-2.5.3.release.jar
The real issue is that for some reason this change makes the Kafka stream bean not to run, and no consuming is being done. It seems to somehow break Spring activation of kafka-streams. There is no error of any kind or no indication that something went wrong. It feels disabled.
Some additional information:
i'm using
implementation 'org.apache.kafka:kafka-streams:2.5.0'
implementation 'org.apache.kafka:kafka-clients:2.5.0'
changing their versions doesn't seem to have any effect.
Assuming nothing else changed (application classes and Kafka configuration) - what might be the cause?
You should not specify versions; let Boot's dependency management manage the versions. The current Boot 2.5 version is 2.5.7; it requires spring-kafka 2.7.9 - see the project page for the dependency matrix.
https://spring.io/projects/spring-kafka

Error occurred during initialization of boot layer spring framework

When I am running my code the Console shows the following error
"Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for
C:\Users\Ankit
Singh\Downloads\spring-framework-5.1.9.RELEASE\libs\spring-context-indexer-5.1.9.RELEASE-sources.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider
class
org.springframework.context.index.processor.CandidateComponentsIndexer
not in module
Default Package delete.
Reinstalled Spring library
Two different way to call beans
Can someone suggested whats wrong in my system??
You might use a default package, right? I have had the same error as you...
Listen, dude, you can try to click: your project name-properties-java build path, move your external jar(s) from module-path to classpath. Then, you can run the code again.

Getting following error while executing CronJobSchedulingExample

Getting following error while running CronJobSchedulingExample example from github https://github.com/apache/ignite/blob/master/examples/src/main/java-lgpl/org/apache/ignite/examples/misc/schedule/ComputeScheduleExample.java
Exception in thread "main" class org.apache.ignite.IgniteException: Current Ignite configuration does not support schedule functionality (consider adding ignite-schedule module to classpath).
at org.apache.ignite.internal.processors.schedule.IgniteNoopScheduleProcessor.processorException(IgniteNoopScheduleProcessor.java:50)
at org.apache.ignite.internal.processors.schedule.IgniteNoopScheduleProcessor.schedule(IgniteNoopScheduleProcessor.java:43)
at org.apache.ignite.internal.IgniteSchedulerImpl.scheduleLocal(IgniteSchedulerImpl.java:123)
at com.mstorm.ignition.CronJobSchedulingExample.main(CronJobSchedulingExample.java:38)
You need to have ignite-schedule module in project classpath. Check if it's added in your pom.xml or, if you're running it using ignite.sh, - copy ignite-schedule directory from libs/optional to libs.

LUCENE Version conflict between Elasticsearch and project dependency

Project I am working on requires the use of both Elasticsearch and a dependency (I didn't design or get to dictate its design) that utilizes Lucene and running into a version conflict between the two. The following error is spit out when I try to start the project
Exception in thread "main" java.lang.NoSuchFieldError: LUCENE_5_2_1
at org.elasticsearch.Version.<clinit>(Version.java:39)
at org.elasticsearch.common.io.stream.StreamOutput.<init>(StreamOutput.java:74)
at org.elasticsearch.common.io.stream.BytesStreamOutput.<init>(BytesStreamOutput.java:60)
at org.elasticsearch.common.io.stream.BytesStreamOutput.<init>(BytesStreamOutput.java:57)
at org.elasticsearch.common.io.stream.BytesStreamOutput.<init>(BytesStreamOutput.java:47)
at org.elasticsearch.common.xcontent.XContentBuilder.builder(XContentBuilder.java:69)
at org.elasticsearch.common.settings.Setting.arrayToParsableString(Setting.java:726)
at org.elasticsearch.common.settings.Setting.lambda$listSetting$26(Setting.java:672)
at org.elasticsearch.common.settings.Setting$2.getRaw(Setting.java:676)
at org.elasticsearch.common.settings.Setting.lambda$listSetting$24(Setting.java:660)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:665)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:660)
at org.elasticsearch.common.network.NetworkService.<clinit>(NetworkService.java:50)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:91)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:119)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:247)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:92)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:81)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:71)
Any idea on whether or not its possible to resolve without being able to dictate the design of the dependency or Elasticsearch?
Ended up adding the Lucene core dependency version that is being mentioned in the error to the project. build.gradle now contains compile group: 'org.apache.lucene', name: 'lucene-core', version: '5.2.1' and that solved the problem.

Spring Boot Starter Integration and Starter WS not playing well together?

I'm working on a spike to try to exercise a number of technologies with spring boot (1.1.6.RELEASE), gradle (2.1) and Java 1.8. So we are looking at supporting some old style SOAP Web Service calls as well as Spring Integration. So to get off the ground I was looking at working with the example for producing a web service (http://spring.io/guides/gs/producing-web-service/) and adding spring integration into the mix.
When I did this though and try to hit the WSDL location I am now seeing this stack trace :
2014-09-22 09:53:17.823 ERROR 15188 --- [nio-8080-exec-1] a.c.c.C.[.[.[.[messageDispatcherServlet] : Servlet.service() for servlet[messageDispatcherServlet] in
context with path [] threw exception [Request processing failed; nested exception is java.lang.AbstractMethodError: org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z] with root cause
java.lang.AbstractMethodError: org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:377)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:131)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:98)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:699)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:743)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:357)
at org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter.handle(WsdlDefinitionHandlerAdapter.java:144)...
Looking around this looks to be related to the Xerces implementation that is pulled in for Integration. You can reproduce this by taking the example Producing a SOAP web service and changing the dependency section to look like this :
dependencies {
compile("org.springframework.boot:spring-boot-starter-ws")
compile("wsdl4j:wsdl4j:1.6.1")
jaxb("com.sun.xml.bind:jaxb-xjc:2.2.4-1")
compile(files(genJaxb.classesDir).builtBy(genJaxb))
compile("org.springframework.boot:spring-boot-starter-integration")
}
Basically adding compile("org.springframework.boot:spring-boot-starter-integration") and then try hitting the WSDL at http://:/ws/countries.wsdl. (running gradle bootRun)
Now arguably this may not be the best way to do this and maybe I should just look to spring integration to expose the endpoint, but has anyone else seen and dealt with this?
Thanks in advance
Tristan
Note I did add the compile "org.apache.ws.xmlschema:xmlschema-core:2.1.0" dep
Here is my jar list from the lib directory
aopalliance-1.0.jar
aspectjrt-1.8.2.jar
aspectjweaver-1.8.2.jar
classmate-1.0.0.jar
commons-codec-1.2.jar
commons-httpclient-3.0.1.jar
commons-io-2.4.jar
hibernate-validator-5.0.3.Final.jar
jackson-annotations-2.3.0.jar
jackson-core-2.3.4.jar
jackson-databind-2.3.4.jar
jboss-logging-3.1.1.GA.jar
jcl-over-slf4j-1.7.7.jar
jdom-1.0.jar
jul-to-slf4j-1.7.7.jar
log4j-over-slf4j-1.7.7.jar
logback-classic-1.1.2.jar
logback-core-1.1.2.jar
rome-1.0.0.jar
rome-fetcher-1.0.0.jar
slf4j-api-1.7.7.jar
snakeyaml-1.13.jar
spring-aop-4.0.7.RELEASE.jar
spring-beans-4.0.7.RELEASE.jar
spring-boot-1.1.6.RELEASE.jar
spring-boot-autoconfigure-1.1.6.RELEASE.jar
spring-boot-starter-1.1.6.RELEASE.jar
spring-boot-starter-aop-1.1.6.RELEASE.jar
spring-boot-starter-integration-1.1.6.RELEASE.jar
spring-boot-starter-logging-1.1.6.RELEASE.jar
spring-boot-starter-tomcat-1.1.6.RELEASE.jar
spring-boot-starter-web-1.1.6.RELEASE.jar
spring-boot-starter-ws-1.1.6.RELEASE.jar
spring-context-4.0.7.RELEASE.jar
spring-core-4.0.7.RELEASE.jar
spring-expression-4.0.7.RELEASE.jar
spring-integration-core-4.0.3.RELEASE.jar
spring-integration-file-4.0.3.RELEASE.jar
spring-integration-http-4.0.3.RELEASE.jar
spring-integration-ip-4.0.3.RELEASE.jar
spring-integration-stream-4.0.3.RELEASE.jar
spring-jms-4.0.7.RELEASE.jar
spring-messaging-4.0.7.RELEASE.jar
spring-oxm-4.0.7.RELEASE.jar
spring-retry-1.1.0.RELEASE.jar
spring-tx-4.0.7.RELEASE.jar
spring-web-4.0.7.RELEASE.jar
spring-webmvc-4.0.7.RELEASE.jar
spring-ws-core-2.2.0.RELEASE.jar
spring-ws-support-2.2.0.RELEASE.jar
spring-xml-2.2.0.RELEASE.jar
tomcat-embed-core-7.0.55.jar
tomcat-embed-el-7.0.55.jar
tomcat-embed-logging-juli-7.0.55.jar
validation-api-1.1.0.Final.jar
wsdl4j-1.6.1.jar
xercesImpl-2.4.0.jar
xmlschema-core-2.1.0.jar
Looks like for the WSDL generation you should provide this dependency:
compile "org.apache.ws.xmlschema:xmlschema-core:2.1.0"
Which is optional from the Spring WS and looks like there is no appropriate implementation in your environment.
UPDATE
Try to add xalan too:
compile "xalan:xalan:2.7.1"
https://groups.google.com/forum/#!topic/google-web-toolkit/07rVeEkCtyU
Or do some tricks with Xerses: java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String

Categories