Could not write JSON: No serializer found for class net.i2p.crypto.eddsa.math.ed25519.Ed25519LittleEndianEncoding

i try to implement spring web server to a cordapp , but continuously getting same Serialization error.

{
"timestamp": 1529999846743,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.http.converter.HttpMessageNotWritableException",
"message": "org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class net.i2p.crypto.eddsa.math.ed25519.Ed25519LittleEndianEncoding and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class net.i2p.crypto.eddsa.math.ed25519.Ed25519LittleEndianEncoding and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.ArrayList[0]->java.util.Collections$SingletonMap[\"state\"]->java.util.Collections$SingletonMap[\"data\"]->java.util.LinkedHashMap[\"exitKeys\"]->java.util.LinkedHashSet[0]->net.i2p.crypto.eddsa.EdDSAPublicKey[\"params\"]->net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec[\"curve\"]->net.i2p.crypto.eddsa.math.Curve[\"field\"]->net.i2p.crypto.eddsa.math.Field[\"encoding\"])",
"path": "/api/obligation/cash"

}

Basically you're trying to serialize an object of class net.i2p.crypto.eddsa.math.ed25519.Ed25519LittleEndianEncoding and as you can see in the sources this class has no fields, which causes the serialization to fail.

You should add this line to your mapper configuration:

mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);

then see if the output is what you want.

Edit: According to Spring Boot documentation, you can add this configuration to the default mapper by adding

spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false

to your application.properties file.

Customising Spring Boot Exception Handling to Prevent Stacktraces , It may not be the "cleanest" approach, but with projects I've been on we had We can throw this error from a rest GET mapping when a data is not found like : that handles exception of the type Exception.class, that way you don't have Reference from : https://www.javaguides.net/2019/02/spring-boot-2-  Objective: Create an API that allows me to search for data in the article journal, retrieve its data in a class Item, display it in Json format. Path: I created a project on Liferay 6.1 using the S

create an ObjectMapper in a @Configuration class like this :

@Configuration
class Plugin {

   @Bean
   fun registerModule(): ObjectMapper {
      return JacksonSupport.createNonRpcMapper()
   }
}

and you are good to go !

Error while retrieving the Corda IOU State using webserver spring , It seems i need to configure with Jackson but i dont know how to do that. InvalidDefinitionException: No serializer found for class net.i2p.crypto.eddsa.​math.ed25519.Ed25519LittleEndianEncoding and no properties discovered to create  Explains how to use JSON serialization and deserialization in WCF DataContracts.

This error throws when Jackson tries to serialize the PublicKey class to JSON format. Corda provides Jackson support for some intrinsic classes and you have to register that module in Spring:

  1. Add corda-jackson dependency in your spring project.

    net.corda:corda-jackson:3.1-corda

  2. Register the Corda Jackson Support Module for your spring project. You can do it using java config as below:

@Bean public Module registerModule() { return JacksonSupport.INSTANCE.getCordaModule(); }

JsonParseException: Invalid JSON input. Position: 9. Character , It seems i need to configure with Jackson but i dont know how to do that. InvalidDefinitionException: No serializer found for class net.i2p.crypto.eddsa.​math.ed25519.Ed25519LittleEndianEncoding and no properties discovered to create  When you are using rest_framework you shouldn't use json.dumps yourself, since the renderers do this work for you. The data you see is the python dictionary, which is the output of the serializer. It does not get rendered by DRF, because you are are returning a Django StreamingHttpResponse. This data needs to be rendered to get your JSON.

Please use this at class level for the bean:

@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler"})

spring-boot: Не удалось записать JSON: не найден сериализатор , HttpMessageNotWritableException: Could not write JSON: No serializer found for class net.i2p.crypto.eddsa.math.ed25519.Ed25519LittleEndianEncoding and no properties discovered to create BeanSerializer (to avoid exception, disable  ElasticSearch return json exception Could not write content: No serializer found for class org.elasticsearch.common.text.Text and no properties discovered to

InvalidDefinitionException: No serializer found for class net.i2p.crypto.eddsa.​math.ed25519.Ed25519LittleEndianEncoding and no properties  I have no need to de-serialize this format. It is intended as a one-way operation. If someone wishes also to explain how to de-serialize my custom format as well that is an interesting bonus, but definitely not necessary to answer this question. Appendix. Below is the TraceConverter I had made. It references a FieldMetaData class that simply

Q&A for peer programmer code reviews. Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Comments
  • I tried both the approaches but non is working in my case i think this configuration [ pastebin.com/iPuN6J83 ] is creating problem when i remove this configuration and add spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false in application.properties then everything is working fine.
  • 1. I made a mistake and you should of course set spring.jackson.serialization.FAIL_ON_EMPTY_BEANS to false rather than true to disable the exception (which you did) - I already fixed my answer. 2. I don't think the exception has naything to do with the configuration you mentioned, but rather with the object returned by your /api/obligation/cash endpoint.
  • I suspect, this leads to registration of additional mapper in Spring container, but Spring ignore this objectmapper uses default one... You can force Spring to use registered mapper refer stackoverflow.com/questions/51895899/…
  • cordaModule() is deprecated now.