AWS Textract: Exception in thread "main" java.lang.NoSuchMethodError - java

I get this error while executing the AWS Tetxtract API .
Exception in thread "main" java.lang.NoSuchMethodError:
com.amazonaws.client.AwsSyncClientParams.getAdvancedConfig()Lcom/amazonaws/client/builder/AdvancedConfig;
at
com.amazonaws.services.textract.AmazonTextractClient.(AmazonTextractClient.java:149)
at
com.amazonaws.services.textract.AmazonTextractClient.(AmazonTextractClient.java:133)
at
com.amazonaws.services.textract.AmazonTextractClientBuilder.build(AmazonTextractClientBuilder.java:61)
at
com.amazonaws.services.textract.AmazonTextractClientBuilder.build(AmazonTextractClientBuilder.java:27)
at
com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
at
com.tr.fundamental.s3FileUploader.AnalyzeDocument.main(AnalyzeDocument.java:177)
I have downloaded the latest Textract jar and included in my build path .
I do not get any compilation error ,but when i run i get this error at this point
// Call AnalyzeDocument
EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
AmazonTextract client = AmazonTextractClientBuilder.standard().withEndpointConfiguration(endpoint).build();
My credential and all are correct and able to connect to S3 as well.
I am not sure what i am missing .
Please help

A possible issue is that you are using difference artefact versions your aws libraries.
In case you are using Maven, have a look on:
https://stackoverflow.com/a/55330900/2353294

Ok let me answer my question .
So using Default client solved my issue .
EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
AmazonTextract client = AmazonTextractClientBuilder.defaultClient();

This is happening due to version mismatch of aws sdk and textract. Keep same version, it would start working

I was also getting the same issue, I have degraded the version and the issue get resolved.
It happens due to version mismatch.

Related

Java agent OTel not working with New Relic

I have a Java application running with an OTel agent to collect telemetries and send them to the New Relic platform.
Configuration of OTel Java agent:
-javaagent:./agents/opentelemetry-javaagent-all.jar
-Dotel.traces.exporter=otlp
-Dotel.resource.attributes=service.name=my-application
-Dotel.exporter.otlp.endpoint=https://otlp.nr-data.net:4317
-Dotel.exporter.otlp.headers=api-key=${NEW_RELIC_LICENSE_KEY}
When this app is starting an error occurs:
Caused by: java.lang.IllegalArgumentException: cannot find a NameResolver for https://otlp.nr-data.net:4317
How to resolve this problem?
I would try:
-Dotel.exporter.otlp.endpoint=otlp.nr-data.net:4317
OTLP endpoint should be officially URL (so scheme part should be included), but some implementations need it without scheme part. I guess this is your case.
The problem has been solved for me when adjusting Dockerfile forcing the download of OTel java agent on the image build process.
From:
COPY ./agents/opentelemetry-javaagent-all.jar .
To:
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.12.1/opentelemetry-javaagent.jar .

java.lang.NoClassDefFoundError when running read_stream_kafka using sparklyr library in R

I am trying to stream data from kafka producer to R for processing using sparklyr but when I run the read_stream_kafka() function i get an error below:
read_options = list(kafka.bootstrap.server = "localhost:9092", subscribe = "topic")
> stream = stream_read_kafka(sc, options = read_options)
Error:java.lang.NoClassDefFoundError:org/apache/kafka/common/serialization/ByteArrayDeserializer
Caused by: java.lang.ClassNotFoundException:org.apache.kafka.common.serialization.ByteArrayDeserializer
I am using the Docker platform to contain the KAFKA and zookeeper container.
I also ensured that i am using java8, and I have already initialised the following paths: SPARK_HOME, SCALA_HOME, and JAVA_HOME as well.
I also added the rkafka and rjava library since I suspected its probably because I havent included the kafka library but the error is still there.
Further information that may be useful to help solve this challenge include:
My kafka version is kafka_2.13_2.8.1, the spark version is spark-2.8.4-bin-hadoop2.7, the scala version is 2.12, and the R version is 4.1.1. Might the error be resulting from a compatibility issue. If so, then how do i solve this.
Please assist on this
Many thanks

Java web service client giving JaxWsClientProxy.invoke error

I am working on a Java web service client development . I am using STS tool and Maven apache cxf plugin , Java 1.8. While executing it , I am getting following error for JaxWsClientProxy:
javax.xml.ws.soap.SOAPFaultException: Response message did not contain proper response data.
Expected: {<targetNameSpace>}ServerResponseMessage
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:161)
at com.sun.proxy.$Proxy40.createdEndDeviceControls(Unknown Source)
In my pom.xml I have only added the cxf-spring-boot-starter-jaxws for version 3.2.4 dependency.
Can someone please let me know what is the reason for this error . The method createdEndDeviceControls exists in the corresponding Port
Please Help .
Best Regards,
Sudeshna Bhattacharya

Issue with SMB API while connecting to remote share folder using Java

artifact : smbj
version : 0.3.0
Able to connect to the server but when it try to access the
DiskShare share = (DiskShare) session.connectShare(sambaSharedPath);
Below Exception is throwing. Please suggest fix.
com.hierynomus.mssmb2.SMBApiException: STATUS_BAD_NETWORK_PATH(3221225662/3221225662): Could not connect to \\SharePatch\
at com.hierynomus.smbj.session.Session.connectTree(Session.java:113)
at com.hierynomus.smbj.session.Session.connectShare(Session.java:98)
at com.smbj.test.CreateNASFile.upload(CreateNASFile.java:71)
at com.smbj.test.CreateNASFile.main(CreateNASFile.java:107)
Issue got resolved after passing shaereName and sharePath separately (We should not pass full combined path).

AWS Java NoSuchMethodError using IVONA Text to Speech

I have started using IVONA TTS and AWS is a dependancy of it, so I have also imported that to the project. My problem is that when running even the sample Java application I get the following error:
Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.auth.AWS4Signer.presignRequest(Lcom/amazonaws/Request;Lcom/amazonaws/auth/AWSCredentials;Ljava/util/Date;)V
at com.ivona.services.tts.IvonaSpeechCloudClient.prepareRequest(IvonaSpeechCloudClient.java:292)
at com.ivona.services.tts.IvonaSpeechCloudClient.prepareRequestForGetUrl(IvonaSpeechCloudClient.java:270)
at com.ivona.services.tts.IvonaSpeechCloudClient.getCreateSpeechUrl(IvonaSpeechCloudClient.java:159)
at filetest.TextToSpeech.main(TextToSpeech.java:49)
TextToSpeech.java:49 being:
System.out.println("Requested URL: " + speechCloud.getCreateSpeechUrl(createSpeechRequest));
I'm using AWS version 1.10.12 (latest), but I've also tried several other previous versions only to get the same error. I've checked the class file "AWS4Signer", and the method "presignRequest" does exist, so I'm confused as to why I'm getting this error. If needed, here is the sample I used.
I'll be happy to add any more information if required. Any help would be greatly appreciated.
Your error is NoSuchMethod - I suspect that there is a version mismatch. Check from Ivona which version of AWS you need to use. According to Ivona's pom.xml it is 1.9.19.

Categories