Spring, Apache Avro, Allargs constructor











up vote
1
down vote

favorite












I have a problem deserialising messages which have been posted to a Kafka topic. I'm using spring-boot, spring cloud stream, apache kafka, and apache avro. The object I am trying to deserialise has a constructor which takes in two args. I am getting an exception when taking a message from the topic:



org.springframework.messaging.MessagingException: Exception thrown while invoking com.foo.bar.messaging.ResponseListener#handleResponse[1 args]; 
nested exception is java.lang.RuntimeException: java.lang.NoSuchMethodException: com.foo.bar.TheObject.<init>() at org.springframework.cloud.stream.binding.StreamListenerMessageHandler.handleRequestMessage(StreamListenerMessageHandler.java:63) ~[spring-cloud-stream-2.0.1.RELEASE.jar:2.0.1.RELEASE]


The class which is being deserialised has a constructor which takes 2 args, and looks like this:



public class TheObject {
private final int thingOne;
private final int thingTwo;
@JsonCreator
public TheObject(@JsonProperty("thingOne") int thingOne, @JsonProperty("thingTwo") int thingTwo) {
this.thingOne = thingOne;
this.thingTwo = thingTwo;
}
}


Previously I used Jackson, and just posted Strings to the kafka topic, so the @JsonCreator annotation was enough to tell the mapper how to construct the object, but I'm now changing to use Arvo. Jackson is no longer used at all for this serialisation. I have left the annotations on the example above to show how it used to work.



In terms of configuration, I am using a property: dynamicSchemaGenerationEnabled: true and not explicitly declaring object schemas. This seems to be working fine with both the spring Schema Registry, and Confluent Schema Registry (apart from the problem described here)



Is there an equivalent to the @JsonCreator annotation that will work with the Arvo deserialisation?



thanks










share|improve this question
























  • for jackson you need the default empty constructor see stackoverflow.com/a/50736606/3224238
    – Paizo
    2 days ago










  • @Paizo that is not true. You do not need a 'default empty constructor' for Jackson. Jackson will already deserialise this class. The problem is that I am now using Avro, which does not use Jackson, therefore my deserialisation is no longer working
    – robjwilkins
    2 days ago










  • Jackson supports many formats, actually. github.com/FasterXML/jackson-dataformats-binary/blob/master/… But Spring Kafka has a separate class/config for the Avro schema registry, and it's not clear if you're using that
    – cricket_007
    2 days ago










  • I am no longer using Jackson at all. I was previously, but it has been removed. I left the annotations on the example as I want to continue using the same constructor. I have not explicitly declared a schema - I have set a property: dynamicSchemaGenerationEnabled: true
    – robjwilkins
    2 days ago















up vote
1
down vote

favorite












I have a problem deserialising messages which have been posted to a Kafka topic. I'm using spring-boot, spring cloud stream, apache kafka, and apache avro. The object I am trying to deserialise has a constructor which takes in two args. I am getting an exception when taking a message from the topic:



org.springframework.messaging.MessagingException: Exception thrown while invoking com.foo.bar.messaging.ResponseListener#handleResponse[1 args]; 
nested exception is java.lang.RuntimeException: java.lang.NoSuchMethodException: com.foo.bar.TheObject.<init>() at org.springframework.cloud.stream.binding.StreamListenerMessageHandler.handleRequestMessage(StreamListenerMessageHandler.java:63) ~[spring-cloud-stream-2.0.1.RELEASE.jar:2.0.1.RELEASE]


The class which is being deserialised has a constructor which takes 2 args, and looks like this:



public class TheObject {
private final int thingOne;
private final int thingTwo;
@JsonCreator
public TheObject(@JsonProperty("thingOne") int thingOne, @JsonProperty("thingTwo") int thingTwo) {
this.thingOne = thingOne;
this.thingTwo = thingTwo;
}
}


Previously I used Jackson, and just posted Strings to the kafka topic, so the @JsonCreator annotation was enough to tell the mapper how to construct the object, but I'm now changing to use Arvo. Jackson is no longer used at all for this serialisation. I have left the annotations on the example above to show how it used to work.



In terms of configuration, I am using a property: dynamicSchemaGenerationEnabled: true and not explicitly declaring object schemas. This seems to be working fine with both the spring Schema Registry, and Confluent Schema Registry (apart from the problem described here)



Is there an equivalent to the @JsonCreator annotation that will work with the Arvo deserialisation?



thanks










share|improve this question
























  • for jackson you need the default empty constructor see stackoverflow.com/a/50736606/3224238
    – Paizo
    2 days ago










  • @Paizo that is not true. You do not need a 'default empty constructor' for Jackson. Jackson will already deserialise this class. The problem is that I am now using Avro, which does not use Jackson, therefore my deserialisation is no longer working
    – robjwilkins
    2 days ago










  • Jackson supports many formats, actually. github.com/FasterXML/jackson-dataformats-binary/blob/master/… But Spring Kafka has a separate class/config for the Avro schema registry, and it's not clear if you're using that
    – cricket_007
    2 days ago










  • I am no longer using Jackson at all. I was previously, but it has been removed. I left the annotations on the example as I want to continue using the same constructor. I have not explicitly declared a schema - I have set a property: dynamicSchemaGenerationEnabled: true
    – robjwilkins
    2 days ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a problem deserialising messages which have been posted to a Kafka topic. I'm using spring-boot, spring cloud stream, apache kafka, and apache avro. The object I am trying to deserialise has a constructor which takes in two args. I am getting an exception when taking a message from the topic:



org.springframework.messaging.MessagingException: Exception thrown while invoking com.foo.bar.messaging.ResponseListener#handleResponse[1 args]; 
nested exception is java.lang.RuntimeException: java.lang.NoSuchMethodException: com.foo.bar.TheObject.<init>() at org.springframework.cloud.stream.binding.StreamListenerMessageHandler.handleRequestMessage(StreamListenerMessageHandler.java:63) ~[spring-cloud-stream-2.0.1.RELEASE.jar:2.0.1.RELEASE]


The class which is being deserialised has a constructor which takes 2 args, and looks like this:



public class TheObject {
private final int thingOne;
private final int thingTwo;
@JsonCreator
public TheObject(@JsonProperty("thingOne") int thingOne, @JsonProperty("thingTwo") int thingTwo) {
this.thingOne = thingOne;
this.thingTwo = thingTwo;
}
}


Previously I used Jackson, and just posted Strings to the kafka topic, so the @JsonCreator annotation was enough to tell the mapper how to construct the object, but I'm now changing to use Arvo. Jackson is no longer used at all for this serialisation. I have left the annotations on the example above to show how it used to work.



In terms of configuration, I am using a property: dynamicSchemaGenerationEnabled: true and not explicitly declaring object schemas. This seems to be working fine with both the spring Schema Registry, and Confluent Schema Registry (apart from the problem described here)



Is there an equivalent to the @JsonCreator annotation that will work with the Arvo deserialisation?



thanks










share|improve this question















I have a problem deserialising messages which have been posted to a Kafka topic. I'm using spring-boot, spring cloud stream, apache kafka, and apache avro. The object I am trying to deserialise has a constructor which takes in two args. I am getting an exception when taking a message from the topic:



org.springframework.messaging.MessagingException: Exception thrown while invoking com.foo.bar.messaging.ResponseListener#handleResponse[1 args]; 
nested exception is java.lang.RuntimeException: java.lang.NoSuchMethodException: com.foo.bar.TheObject.<init>() at org.springframework.cloud.stream.binding.StreamListenerMessageHandler.handleRequestMessage(StreamListenerMessageHandler.java:63) ~[spring-cloud-stream-2.0.1.RELEASE.jar:2.0.1.RELEASE]


The class which is being deserialised has a constructor which takes 2 args, and looks like this:



public class TheObject {
private final int thingOne;
private final int thingTwo;
@JsonCreator
public TheObject(@JsonProperty("thingOne") int thingOne, @JsonProperty("thingTwo") int thingTwo) {
this.thingOne = thingOne;
this.thingTwo = thingTwo;
}
}


Previously I used Jackson, and just posted Strings to the kafka topic, so the @JsonCreator annotation was enough to tell the mapper how to construct the object, but I'm now changing to use Arvo. Jackson is no longer used at all for this serialisation. I have left the annotations on the example above to show how it used to work.



In terms of configuration, I am using a property: dynamicSchemaGenerationEnabled: true and not explicitly declaring object schemas. This seems to be working fine with both the spring Schema Registry, and Confluent Schema Registry (apart from the problem described here)



Is there an equivalent to the @JsonCreator annotation that will work with the Arvo deserialisation?



thanks







java spring apache-kafka deserialization avro






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago

























asked 2 days ago









robjwilkins

2,32022034




2,32022034












  • for jackson you need the default empty constructor see stackoverflow.com/a/50736606/3224238
    – Paizo
    2 days ago










  • @Paizo that is not true. You do not need a 'default empty constructor' for Jackson. Jackson will already deserialise this class. The problem is that I am now using Avro, which does not use Jackson, therefore my deserialisation is no longer working
    – robjwilkins
    2 days ago










  • Jackson supports many formats, actually. github.com/FasterXML/jackson-dataformats-binary/blob/master/… But Spring Kafka has a separate class/config for the Avro schema registry, and it's not clear if you're using that
    – cricket_007
    2 days ago










  • I am no longer using Jackson at all. I was previously, but it has been removed. I left the annotations on the example as I want to continue using the same constructor. I have not explicitly declared a schema - I have set a property: dynamicSchemaGenerationEnabled: true
    – robjwilkins
    2 days ago


















  • for jackson you need the default empty constructor see stackoverflow.com/a/50736606/3224238
    – Paizo
    2 days ago










  • @Paizo that is not true. You do not need a 'default empty constructor' for Jackson. Jackson will already deserialise this class. The problem is that I am now using Avro, which does not use Jackson, therefore my deserialisation is no longer working
    – robjwilkins
    2 days ago










  • Jackson supports many formats, actually. github.com/FasterXML/jackson-dataformats-binary/blob/master/… But Spring Kafka has a separate class/config for the Avro schema registry, and it's not clear if you're using that
    – cricket_007
    2 days ago










  • I am no longer using Jackson at all. I was previously, but it has been removed. I left the annotations on the example as I want to continue using the same constructor. I have not explicitly declared a schema - I have set a property: dynamicSchemaGenerationEnabled: true
    – robjwilkins
    2 days ago
















for jackson you need the default empty constructor see stackoverflow.com/a/50736606/3224238
– Paizo
2 days ago




for jackson you need the default empty constructor see stackoverflow.com/a/50736606/3224238
– Paizo
2 days ago












@Paizo that is not true. You do not need a 'default empty constructor' for Jackson. Jackson will already deserialise this class. The problem is that I am now using Avro, which does not use Jackson, therefore my deserialisation is no longer working
– robjwilkins
2 days ago




@Paizo that is not true. You do not need a 'default empty constructor' for Jackson. Jackson will already deserialise this class. The problem is that I am now using Avro, which does not use Jackson, therefore my deserialisation is no longer working
– robjwilkins
2 days ago












Jackson supports many formats, actually. github.com/FasterXML/jackson-dataformats-binary/blob/master/… But Spring Kafka has a separate class/config for the Avro schema registry, and it's not clear if you're using that
– cricket_007
2 days ago




Jackson supports many formats, actually. github.com/FasterXML/jackson-dataformats-binary/blob/master/… But Spring Kafka has a separate class/config for the Avro schema registry, and it's not clear if you're using that
– cricket_007
2 days ago












I am no longer using Jackson at all. I was previously, but it has been removed. I left the annotations on the example as I want to continue using the same constructor. I have not explicitly declared a schema - I have set a property: dynamicSchemaGenerationEnabled: true
– robjwilkins
2 days ago




I am no longer using Jackson at all. I was previously, but it has been removed. I left the annotations on the example as I want to continue using the same constructor. I have not explicitly declared a schema - I have set a property: dynamicSchemaGenerationEnabled: true
– robjwilkins
2 days ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373541%2fspring-apache-avro-allargs-constructor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373541%2fspring-apache-avro-allargs-constructor%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

WPF add header to Image with URL pettitions [duplicate]