ScaCap / spring-auto-restdocs

Spring Auto REST Docs is an extension to Spring REST Docs
https://scacap.github.io/spring-auto-restdocs/
Apache License 2.0
311 stars 86 forks source link

Can not construct instance of capital.scalable.restdocs.javadoc.ClassJavadoc$FieldJavadoc #170

Closed ls-arnaud-levallois closed 7 years ago

ls-arnaud-levallois commented 7 years ago

I am using a build of the version 1.0.10-SNAPSHOT since a few weeks. I tried the new 1.0.10 release but I get errors like :

2017-11-03 15:24:46.777 ERROR 33692 --- [           main] c.s.restdocs.javadoc.JavadocReader       : Failed to read file WebhookEndpointController.json

com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of capital.scalable.restdocs.javadoc.ClassJavadoc$FieldJavadoc: no String-argument constructor/factory method to deserialize from String value ('')
 at [Source:<filePath>/WebhookEndpointController.json; line: 1, column: 53] (through reference chain: capital.scalable.restdocs.javadoc.ClassJavadoc["fields"]->java.util.LinkedHashMap["webhookEndpointRepository"])
        at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1456) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1012) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:370) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:315) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1283) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:159) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:150) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:517) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:362) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:27) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:111) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1626) ~[jackson-databind-2.8.9.jar:2.8.9]
        at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1266) ~[jackson-databind-2.8.9.jar:2.8.9]
        at capital.scalable.restdocs.javadoc.JavadocReaderImpl.readJson(JavadocReaderImpl.java:164) [spring-auto-restdocs-core-1.0.10.jar:na]
        at capital.scalable.restdocs.javadoc.JavadocReaderImpl.readFiles(JavadocReaderImpl.java:145) [spring-auto-restdocs-core-1.0.10.jar:na]
        at capital.scalable.restdocs.javadoc.JavadocReaderImpl.classJavadoc(JavadocReaderImpl.java:122) [spring-auto-restdocs-core-1.0.10.jar:na]
        at capital.scalable.restdocs.javadoc.JavadocReaderImpl.resolveCommentFromClassHierarchy(JavadocReaderImpl.java:224) [spring-auto-restdocs-core-1.0.10.jar:na]
        at capital.scalable.restdocs.javadoc.JavadocReaderImpl.resolveMethodComment(JavadocReaderImpl.java:86) [spring-auto-restdocs-core-1.0.10.jar:na]
        at capital.scalable.restdocs.misc.DescriptionSnippet.resolveComment(DescriptionSnippet.java:74) [spring-auto-restdocs-core-1.0.10.jar:na]
        at capital.scalable.restdocs.misc.DescriptionSnippet.createModel(DescriptionSnippet.java:52) [spring-auto-restdocs-core-1.0.10.jar:na]
        at org.springframework.restdocs.snippet.TemplatedSnippet.document(TemplatedSnippet.java:64) [spring-restdocs-core-1.1.3.RELEASE.jar:na]
        at org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:196) [spring-restdocs-core-1.1.3.RELEASE.jar:na]
        at org.springframework.restdocs.mockmvc.RestDocumentationResultHandler.handle(RestDocumentationResultHandler.java:55) [spring-restdocs-mockmvc-1.1.3.RELEASE.jar:na]
        at org.springframework.test.web.servlet.MockMvc.applyDefaultResultActions(MockMvc.java:195) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.springframework.test.web.servlet.MockMvc.perform(MockMvc.java:163) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at com.ikentoo.irene.controller.rest.WebhookEndpointControllerTest.registerWebhookEndpoint(WebhookEndpointControllerTest.java:49) [test-classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) [junit-4.12.jar:4.12]
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) [junit-4.12.jar:4.12]
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) [junit-4.12.jar:4.12]
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) [junit-4.12.jar:4.12]
        at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.springframework.restdocs.JUnitRestDocumentation$1.evaluate(JUnitRestDocumentation.java:55) [spring-restdocs-core-1.1.3.RELEASE.jar:na]
        at org.junit.rules.RunRules.evaluate(RunRules.java:20) [junit-4.12.jar:4.12]
        at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) [junit-4.12.jar:4.12]
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) [spring-test-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283) [surefire-junit4-2.18.1.jar:2.18.1]
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173) [surefire-junit4-2.18.1.jar:2.18.1]
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) [surefire-junit4-2.18.1.jar:2.18.1]
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128) [surefire-junit4-2.18.1.jar:2.18.1]
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203) [surefire-booter-2.18.1.jar:2.18.1]
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155) [surefire-booter-2.18.1.jar:2.18.1]
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) [surefire-booter-2.18.1.jar:2.18.1]

With the SNAPSHOT version, I have no problem

jmisur commented 7 years ago

you generated JSON files are in old format. Regenerate them, e.g. via mvn compile.

ls-arnaud-levallois commented 7 years ago

Thanks for your quick reply. I clean at each build: mvn clean install What do you mean by old format for JSON files?

jmisur commented 7 years ago

We changed the format of JSON files to be more extensible for the future. That said, spring-auto-restdocs-json-doclet docletArtifact must have the same version as spring-auto-restdocs-core dependency, see https://scacap.github.io/spring-auto-restdocs/#gettingstarted-usage

ls-arnaud-levallois commented 7 years ago

That's it! Thanks @jmisur! I tried to early to change the plugin version and it was not available, now it is OK