In my program, I am processing issues from jira.
I wanted to add an extra step to save all of my issues in a yaml file and then, when needed read them again. I am storing the original com.atlassian.jira.rest.client.api.domain.Issue objects in the yaml file (that is why I am using object mappers), since I need them later again as issues.
However, reading these objects seems to be difficult.
These are my methods for saving the issues and reading them:
private static void saveIssuesToYAMLFile(List<Issue> issues, String yamlPath) throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER));
mapper.registerModule(new JodaModule());
try(BufferedWriter writer = new BufferedWriter(new FileWriter(yamlPath, true))) {
mapper.writeValue(writer, issues);
}
}
private static List<Issue> readIssuesFromYAMLFile(String yamlPath) throws IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER));
mapper.registerModule(new JodaModule());
return mapper.readValue(new File(yamlPath), mapper.getTypeFactory().constructCollectionType(List.class, Issue.class));
}
When I try to read the file I get this error:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.atlassian.jira.rest.client.api.domain.Issue` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (File); line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1887)
at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:414)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1375)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1508)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:348)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:361)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:246)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4905)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3753)
at com.jira.jirarestclient.issues.Search.readIssuesFromYAMLFile(SearchClient.java:19)
at com.jira.jirarestclient.issues.Search.readIssuesFromJQL(SearchClient.java:109)
at com.jira.App.main(App.java:7)
Because issue does not seem to have constructors, so remapping is difficult. Does anyone know a workaround or even another file method I can save my issues and read them again?
Saving them as strings or writing my own constructor seems to be my last plan, but I am already processing the issues further a lot and I do not want to change my whole code.
Hi @Tina
This type of question,as it's more developer related I would recommend posting to the developer community: https://community.developer.atlassian.com/
The developer community will have people with more development knowledge rather than atlassian knowledge. There are some developers on here, just not as many as there
Best,
Clark
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.