Closed anil123lalam closed 2 years ago
Hi @anil123lalam,
thanks for using our client.
Can you share a full stacktrace? How looks like your dependency tree?
Regards
Hi bednar, Thanks for your quick response. Dependency tree:
FullStackTrace:
Exception in thread "main" java.lang.IllegalArgumentException: Unable to create @Body converter for class com.influxdb.client.domain.Query (parameter https://github.com/influxdata/influxdb-client-java/pull/6) for method QueryService.postQueryResponseBody at retrofit2.Utils.methodError(Utils.java:54) at retrofit2.Utils.parameterError(Utils.java:60) at retrofit2.RequestFactory$Builder.parseParameterAnnotation(RequestFactory.java:781) at retrofit2.RequestFactory$Builder.parseParameter(RequestFactory.java:325) at retrofit2.RequestFactory$Builder.build(RequestFactory.java:206) at retrofit2.RequestFactory.parseAnnotations(RequestFactory.java:67) at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:26) at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:202) at retrofit2.Retrofit$1.invoke(Retrofit.java:160) at com.sun.proxy.$Proxy4.postQueryResponseBody(Unknown Source) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:933) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:123) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:85) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:75) at com.influxdb.InfluxDBClientSample.main(InfluxDBClientSample.java:49) Caused by: java.lang.IllegalArgumentException: @JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference. at com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.getTypeAdapter(JsonAdapterAnnotationTypeAdapterFactory.java:65) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:133) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(ReflectiveTypeAdapterFactory.java:106) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97) at com.google.gson.Gson.getDelegateAdapter(Gson.java:489) at io.gsonfire.gson.WrapTypeAdapterFactory.create(WrapTypeAdapterFactory.java:26) at com.google.gson.Gson.getAdapter(Gson.java:407) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(ReflectiveTypeAdapterFactory.java:106) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97) at com.google.gson.Gson.getDelegateAdapter(Gson.java:489) at io.gsonfire.gson.WrapTypeAdapterFactory.create(WrapTypeAdapterFactory.java:26) at com.google.gson.Gson.getAdapter(Gson.java:407) at retrofit2.converter.gson.GsonConverterFactory.requestBodyConverter(GsonConverterFactory.java:74) at retrofit2.Retrofit.nextRequestBodyConverter(Retrofit.java:315) at retrofit2.Retrofit.requestBodyConverter(Retrofit.java:293) at retrofit2.RequestFactory$Builder.parseParameterAnnotation(RequestFactory.java:778) ... 12 more
Client Version: com.influxdb influxdb-client-java 5.0.0 InfluxDB Version: 2.2.0 JDK Version: 1.8 Platform:Windows
It looks like problem with gson
version. Please try to change gson
version to 2.8.8
or remove explicit declaration of gson
.
Even after i changed the gson version to 2.8.8 or remove explicit declaration of gson i am seeing the same exceptions.
Can you try the 6.0.0
? This version contains PR https://github.com/influxdata/influxdb-client-java/pull/298 with fixed dependency collision.
When i use 6.0.0, i am getting below exceptions
Exception in thread "main" java.lang.NullPointerException: Expecting a not null reference for InfluxDBClientOptions.getOrg at java.base/java.util.Objects.requireNonNull(Objects.java:347) at com.influxdb.utils.Arguments.checkNotNull(Arguments.java:150) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:132) at com.influxdb.InfluxDBClientSample.main(InfluxDBClientSample.java:28)
This is our bug introduced by #335 :(
Please as a workaround change the initialisation of InfluxDBClientOptions
to (url
as first):
InfluxDBClientOptions build = InfluxDBClientOptions.builder().url("http://localhost:8086").bucket(bucket).org(org)
.authenticateToken(token.toCharArray()).build();
As per your suggestion i have changed the initialization, now i am getting below exception
Exception in thread "main" java.lang.IllegalArgumentException: Unable to create @Body converter for class com.influxdb.client.domain.Query (parameter #6)
for method QueryService.postQueryResponseBody
at retrofit2.Utils.methodError(Utils.java:54)
at retrofit2.Utils.parameterError(Utils.java:60)
at retrofit2.RequestFactory$Builder.parseParameterAnnotation(RequestFactory.java:781)
at retrofit2.RequestFactory$Builder.parseParameter(RequestFactory.java:325)
at retrofit2.RequestFactory$Builder.build(RequestFactory.java:206)
at retrofit2.RequestFactory.parseAnnotations(RequestFactory.java:67)
at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:26)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:202)
at retrofit2.Retrofit$1.invoke(Retrofit.java:160)
at com.sun.proxy.$Proxy4.postQueryResponseBody(Unknown Source)
at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:933)
at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:204)
at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:147)
at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:134)
at com.influxdb.InfluxDBClientSample.main(InfluxDBClientSample.java:28)
Caused by: java.lang.IllegalArgumentException: @JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference.
at com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.getTypeAdapter(JsonAdapterAnnotationTypeAdapterFactory.java:65)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:133)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.
It looks like gson
version problem.
What is an output of:
String version = com.google.gson.internal.GsonBuildConfig.VERSION;
System.out.println("version = " + version);
?
version = 2.8.8
For 6.0.0 what is the suggestable gson version ?
For the client 6.0.0
you have to use 2.9.0
.
version = 2.9.0, i am seeing the same exceptions
I've create the following demo project with v6.0.0 client: https://github.com/bednar/java-client-dependency
Can you try the demo project? For me it works correctly.
Thanks, the above demo project works me correctly as well
Can you share your project? Currently I am not able to find a reason of the exception. 😞
Sure, I will share it with you, currently I am out of station. I need to learn influxdb, Could you please help me with resources like videos,books etc. I am not able to find online.
Thanks Anil Lalam ‐‐--------‐------------------------------------------------ Sent From Mobile
On Fri, 22 Apr 2022, 10:09 am Jakub Bednář, @.***> wrote:
Can you share your project? Currently I am not able to find a reason of the exception. 😞
— Reply to this email directly, view it on GitHub https://github.com/influxdata/influxdb-client-java/issues/338#issuecomment-1105998262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUYMYH2FFXV3VMHAYOEUZJ3VGIUO7ANCNFSM5T3MQDUA . You are receiving this because you were mentioned.Message ID: @.***>
Sure, I will share it with you, currently I am out of station
Thanks
Here are some sources:
Can you test explicitly exclude gson
from client dependency and add gson
as a new dependency in your project:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.influxdb</groupId>
<artifactId>influxdb-client-java</artifactId>
<version>6.0.0</version>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
</exclusions>
</dependency>
?
This issue has been closed because it has not had recent activity. Please reopen if this issue is still important to you and you have additionally information.
package com.unitedrentals.dto;
import java.time.Instant;
import com.influxdb.annotations.Column; import com.influxdb.annotations.Measurement;
@Measurement(name = "series") public class InfluxSeriesDto { @Column String shardId; @Column String equipmentId; @Column String datatimestamp; @Column String tagname; @Column String uom; @Column String datavalue; @Column(timestamp = true) Instant time;
}
public class InfluxDBClientSample {
}
Steps to reproduce: List the minimal actions needed to reproduce the behavior.
Exception in thread "main" java.lang.IllegalArgumentException: Unable to create @Body converter for class com.influxdb.client.domain.Query (parameter #6) for method QueryService.postQueryResponseBody at retrofit2.Utils.methodError(Utils.java:54) at retrofit2.Utils.parameterError(Utils.java:60) at retrofit2.RequestFactory$Builder.parseParameterAnnotation(RequestFactory.java:781) at retrofit2.RequestFactory$Builder.parseParameter(RequestFactory.java:325) at retrofit2.RequestFactory$Builder.build(RequestFactory.java:206) at retrofit2.RequestFactory.parseAnnotations(RequestFactory.java:67) at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:26) at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:202) at retrofit2.Retrofit$1.invoke(Retrofit.java:160) at com.sun.proxy.$Proxy4.postQueryResponseBody(Unknown Source) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:933) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:123) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:85) at com.influxdb.client.internal.QueryApiImpl.query(QueryApiImpl.java:75) at com.influxdb.InfluxDBClientSample.main(InfluxDBClientSample.java:49) Caused by: java.lang.IllegalArgumentException: @JsonAdapter value must be TypeAdapter or TypeAdapterFactory reference. at com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.getTypeAdapter(JsonAdapterAnnotationTypeAdapterFactory.java:65) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:133) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(ReflectiveTypeAdapterFactory.java:106)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
at com.google.gson.Gson.getDelegateAdapter(Gson.java:489)
at io.gsonfire.gson.WrapTypeAdapterFactory.create(WrapTypeAdapterFactory.java:26)
at com.google.gson.Gson.getAdapter(Gson.java:407)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.(ReflectiveTypeAdapterFactory.java:106)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
at com.google.gson.Gson.getDelegateAdapter(Gson.java:489)
at io.gsonfire.gson.WrapTypeAdapterFactory.create(WrapTypeAdapterFactory.java:26)
at com.google.gson.Gson.getAdapter(Gson.java:407)
at retrofit2.converter.gson.GsonConverterFactory.requestBodyConverter(GsonConverterFactory.java:74)
at retrofit2.Retrofit.nextRequestBodyConverter(Retrofit.java:315)
at retrofit2.Retrofit.requestBodyConverter(Retrofit.java:293)
at retrofit2.RequestFactory$Builder.parseParameterAnnotation(RequestFactory.java:778)
... 12 more
Expected behavior: Should display records from influxdb
Actual behavior: Exceptions were thrown
Specifications: