{"action":"created","issue":{"url":"https://api.github.com/repos/benas/random-beans/issues/150","repository_url":"https://api.github.com/repos/benas/random-beans","labels_url":"https://api.github.com/repos/benas/random-beans/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/benas/random-beans/issues/150/comments","events_url":"https://api.github.com/repos/benas/random-beans/issues/150/events","html_url":"https://github.com/benas/random-beans/issues/150","id":160737051,"number":150,"title":"java.lang.InstantiationError: com.fasterxml.jackson.core.ObjectCodec","user":{"login":"maassql","id":1134068,"avatar_url":"https://avatars.githubusercontent.com/u/1134068?v=3","gravatar_id":"","url":"https://api.github.com/users/maassql","html_url":"https://github.com/maassql","followers_url":"https://api.github.com/users/maassql/followers","following_url":"https://api.github.com/users/maassql/following{/other_user}","gists_url":"https://api.github.com/users/maassql/gists{/gist_id}","starred_url":"https://api.github.com/users/maassql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maassql/subscriptions","organizations_url":"https://api.github.com/users/maassql/orgs","repos_url":"https://api.github.com/users/maassql/repos","events_url":"https://api.github.com/users/maassql/events{/privacy}","received_events_url":"https://api.github.com/users/maassql/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-16T19:09:41Z","updated_at":"2016-06-16T20:42:11Z","closed_at":null,"body":"I was very excited to find this project.  Unfortunately, I have run out of time researching this error.  Below is as much information as I can figure you might need.  I am only submitting this so that I might learn something.  I am going to move back to tedious boilerplate code now.  I will set a tag in my codebase in case you want me to provide more information.  Of course, if this is a big 'well duh' for you, I would welcome the learning experience ;).\r\n\r\n#### Console output\r\n```\r\nCaused by: io.github.benas.randombeans.api.ObjectGenerationException: Unable to generate a random instance of type class {my custom class}\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:126)\r\n\tat io.github.benas.randombeans.FieldPopulator.generateRandomValue(FieldPopulator.java:106)\r\n\tat io.github.benas.randombeans.FieldPopulator.populateField(FieldPopulator.java:80)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateField(EnhancedRandomImpl.java:154)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateFields(EnhancedRandomImpl.java:148)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:122)\r\n\t... 62 more\r\nCaused by: io.github.benas.randombeans.api.ObjectGenerationException: Unable to generate a random instance of type class com.fasterxml.jackson.databind.ObjectMapper\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:126)\r\n\tat io.github.benas.randombeans.FieldPopulator.generateRandomValue(FieldPopulator.java:106)\r\n\tat io.github.benas.randombeans.FieldPopulator.populateField(FieldPopulator.java:80)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateField(EnhancedRandomImpl.java:154)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateFields(EnhancedRandomImpl.java:148)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:122)\r\n\t... 67 more\r\nCaused by: io.github.benas.randombeans.api.ObjectGenerationException: Unable to generate a random instance of type class com.fasterxml.jackson.core.JsonFactory\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:126)\r\n\tat io.github.benas.randombeans.FieldPopulator.generateRandomValue(FieldPopulator.java:106)\r\n\tat io.github.benas.randombeans.FieldPopulator.populateField(FieldPopulator.java:80)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateField(EnhancedRandomImpl.java:154)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateFields(EnhancedRandomImpl.java:148)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:122)\r\n\t... 72 more\r\nCaused by: io.github.benas.randombeans.api.ObjectGenerationException: Unable to generate a random instance of type class com.fasterxml.jackson.core.ObjectCodec\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:126)\r\n\tat io.github.benas.randombeans.FieldPopulator.generateRandomValue(FieldPopulator.java:106)\r\n\tat io.github.benas.randombeans.FieldPopulator.populateField(FieldPopulator.java:80)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateField(EnhancedRandomImpl.java:154)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.populateFields(EnhancedRandomImpl.java:148)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:122)\r\n\t... 77 more\r\nCaused by: java.lang.InstantiationError: com.fasterxml.jackson.core.ObjectCodec\r\n\tat sun.reflect.GeneratedSerializationConstructorAccessor12.newInstance(Unknown Source)\r\n\tat java.lang.reflect.Constructor.newInstance(Constructor.java:422)\r\n\tat org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:45)\r\n\tat org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:73)\r\n\tat io.github.benas.randombeans.ObjectFactory.createNewInstance(ObjectFactory.java:69)\r\n\tat io.github.benas.randombeans.ObjectFactory.createInstance(ObjectFactory.java:61)\r\n\tat io.github.benas.randombeans.EnhancedRandomImpl.doPopulateBean(EnhancedRandomImpl.java:112)\r\n\t... 82 more\r\n```\r\n#### POM\r\n```\r\n\t\t<dependency>\r\n\t\t    <groupId>io.github.benas</groupId>\r\n\t\t    <artifactId>random-beans</artifactId>\r\n\t\t    <version>3.0.0</version>\r\n\t\t</dependency>\r\n\t\t<dependency>\r\n\t\t   <groupId>io.github.benas</groupId>\r\n\t\t   <artifactId>random-beans-jodatime</artifactId>\r\n\t\t   <version>3.0.0</version>\r\n\t\t</dependency>\r\n\t\t<dependency>\r\n\t\t\t<groupId>com.fasterxml.jackson.core</groupId>\r\n\t\t\t<artifactId>jackson-databind</artifactId>\r\n\t\t\t<version>2.7.4</version>\r\n\t\t</dependency>\r\n```\r\n#### Location\r\n```\r\n\r\nimport com.fasterxml.jackson.annotation.JsonCreator;\r\n\r\nimport {my_company's_path}.A_ParamStruct;\r\n\r\npublic class Location \r\n\textends \tA_ParamStruct\r\n{\r\n\tprivate static final long serialVersionUID = 5713143987689681018L;\r\n\t\r\n\t@JsonCreator\r\n\tpublic Location ( float latitude, float longitude ) { this.latitude = latitude; this.longitude = longitude; }\r\n\tpublic float\tlatitude;\r\n\tpublic float\tlongitude;\r\n}\r\n```\r\n#### A_ParamStruct\r\n```\r\n\r\nimport java.io.Serializable;\r\n\r\n@SuppressWarnings(\"serial\")\r\npublic abstract class A_ParamStruct \r\n\textends A_SerializesToJson\r\n\timplements \r\n\t\t\t  I_ParamStruct\r\n\t\t\t, Cloneable\r\n\t\t\t, Serializable \r\n{\r\n\r\n}\r\n\r\n```\r\n\r\n#### A_SerializesToJson\r\n```\r\nimport com.fasterxml.jackson.annotation.JsonInclude.Include;\r\nimport com.fasterxml.jackson.core.JsonProcessingException;\r\nimport com.fasterxml.jackson.databind.ObjectMapper;\r\n\r\npublic abstract class A_SerializesToJson \r\n{\r\n\t\r\n\tprivate final static org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger();\r\n\t\r\n\tprotected ObjectMapper jacksonMapper = _s_get_Jackson_ObjectMapper();\r\n\t\r\n\tprivate static ObjectMapper _s_get_Jackson_ObjectMapper()\r\n\t{\r\n\t\tObjectMapper ret = new ObjectMapper();\r\n\t\t// http://stackoverflow.com/questions/11757487/how-to-tell-jackson-to-ignore-a-field-during-serialization-if-its-value-is-null\r\n\t\tret.setSerializationInclusion(Include.NON_NULL);\r\n\t\treturn ret;\r\n\t}\r\n\t\r\n\t\r\n\tpublic String asJsonString()\r\n\t{\r\n\t\tString ret = null;\r\n\t\ttry \r\n\t\t{\r\n\t\t\t// Convert object to JSON string and pretty print\r\n\t\t\tret = this.jacksonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(this);\r\n\t\t} \r\n\t\tcatch (JsonProcessingException e) \r\n\t\t{\r\n\t\t\tlogger.error(\"asJsonString()  |  error converting object to json.\", e);\r\n\t\t}\r\n\t\treturn ret;\r\n\t}\r\n\tpublic String \t\t\ttoString() \t\t\t\t\t\t\t\t\t\t\t\t\t{ return this.asJsonString(); }\r\n\r\n}\r\n```\r\n#### I_ParamStruct \r\n```\r\nimport {my company's path}.I_ResponseContent;\r\n\r\n\r\npublic interface I_ParamStruct \r\n\textends I_ResponseContent\r\n{\r\n\t\r\n}\r\n\r\n```\r\n\r\n#### I_ResponseContent  \r\n```\r\npublic interface I_ResponseContent \r\n{\r\n\tString asJsonString();\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/benas/random-beans/issues/comments/226607615","html_url":"https://github.com/benas/random-beans/issues/150#issuecomment-226607615","issue_url":"https://api.github.com/repos/benas/random-beans/issues/150","id":226607615,"user":{"login":"PascalSchumacher","id":2707245,"avatar_url":"https://avatars.githubusercontent.com/u/2707245?v=3","gravatar_id":"","url":"https://api.github.com/users/PascalSchumacher","html_url":"https://github.com/PascalSchumacher","followers_url":"https://api.github.com/users/PascalSchumacher/followers","following_url":"https://api.github.com/users/PascalSchumacher/following{/other_user}","gists_url":"https://api.github.com/users/PascalSchumacher/gists{/gist_id}","starred_url":"https://api.github.com/users/PascalSchumacher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PascalSchumacher/subscriptions","organizations_url":"https://api.github.com/users/PascalSchumacher/orgs","repos_url":"https://api.github.com/users/PascalSchumacher/repos","events_url":"https://api.github.com/users/PascalSchumacher/events{/privacy}","received_events_url":"https://api.github.com/users/PascalSchumacher/received_events","type":"User","site_admin":false},"created_at":"2016-06-16T20:42:11Z","updated_at":"2016-06-16T20:42:11Z","body":"Classpath scanning won't help, as `ObjectCodec` subclasses can not be created by random beans.\r\n\r\nTry excluding `ObjectCodec` from randomization e.g.:\r\n\r\n`EnhancedRandomBuilder.aNewEnhancedRandomBuilder().randomize(ObjectCodec.class, new SkipRandomizer()).build().nextObject(YourClass.class);`"}}
{"actor":{"display_login":"PascalSchumacher"}}