Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "info.archinnov.achilles.exception.AchillesTranscodingException: com.fasterxml.jackson.databind.JsonMappingException" while reading the JSON from Cassandra DB #356

Open
mandarsgujar opened this issue Jan 18, 2019 · 5 comments

Comments

@mandarsgujar
Copy link

mandarsgujar commented Jan 18, 2019

The Entity annotated with @table has some json columns like:
@column
private Map <String, @JSON Address>;

An Exception is thrown while reading such table having JSON type columns. I verified that the JSON is valid and also the write operation was executed successfully.

Following is the sample code, using Achilles core lib version 5.3.1, which throws the above exception:
UserEntity userEntity = userEntityManager.dsl().select().allColumns_FromBaseTable().where().userId().Eq(userId).getOne();

Exception:
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: ; line: 1, column: 0]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3854)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3799)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2896)
at info.archinnov.achilles.internals.codec.JSONCodec.decode(JSONCodec.java:80)
... 49 common frames omitted
Wrapped by: info.archinnov.achilles.exception.AchillesTranscodingException: com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: ; line: 1, column: 0]
at info.archinnov.achilles.internals.codec.JSONCodec.decode(JSONCodec.java:82)
at info.archinnov.achilles.internals.codec.JSONCodec.decode(JSONCodec.java:32)
at info.archinnov.achilles.internals.metamodel.SimpleProperty.decodeFromRawInternal(SimpleProperty.java:121)
at info.archinnov.achilles.internals.metamodel.AbstractProperty.decodeFromRaw(AbstractProperty.java:144)
at info.archinnov.achilles.internals.metamodel.MapProperty.lambda$decodeFromRawInternal$630(MapProperty.java:212)

I found that, this exception used to happen when there is a connection problem with Cassandra node like min. required replicas are not available (I'm using read and write consistency: LOCAL_QUORUM).
I referred similar problem: https://stackoverflow.com/questions/26925058/no-content-to-map-due-to-end-of-input-jackson-parser

Is there any other issue apart from the connection issue?

@doanduyhai
Copy link
Owner

I'm not sure it's an issue related to Achilles. Try to:

  • fetch the map content as Java map instead of JSON string
  • encode the map into JSON yourself using Jackson

If the same error occurs, it means that it's a JSON encoding issue, not related to Achilles

@mandarsgujar
Copy link
Author

@doanduyhai
I am using Java Map in the model class annotated with @table while fetching the data from DB. So, your first suggestion is already followed.
My actual Map type column:
@column
private Map <String, @JSON Address>;

& Query:
UserEntity userEntity = userEntityManager.dsl().select().allColumns_FromBaseTable().where().userId().Eq(userId).getOne();

The seconds suggestion is already implemented in Achilles code 'info.archinnov.achilles.internals.codec.JSONCodec' class.

@doanduyhai
Copy link
Owner

Did you try this mapping:

@column
private Map <String, Address>;

Did Achilles successfully decode the Address UDT ?

@mandarsgujar
Copy link
Author

mandarsgujar commented Jan 24, 2019

Yes, I've used this too, it works. But the tables having such UDT are read rarely so I didn't face such issue there.
This issue only happens when there are Cassandra Connection issues - either required no. of replicas are not available or there is network connection problem from the application node to Cassandra.

In the absence of such Cassandra problems, this works without any issues. I wanted to see if there is any other issues.

Thanks @doanduyhai

@doanduyhai
Copy link
Owner

"This issue only happens when there are Cassandra Connection issues - either required no. of replicas are not available or there is network connection problem from the application node to Cassandra." --> I think the real problem comes from Cassandra and not Achilles ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants