zyro23 / grails-spring-websocket

93 stars 28 forks source link

I am getting this error on grails 2.4.3 #48

Closed yasmani16 closed 7 years ago

yasmani16 commented 7 years ago

2017-05-16 17:04:36,575 ERROR context.GrailsContextLoaderListener - Error initializing the application: Could not read JSON: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@47e235d2; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@47e235d2; line: 1, column: 1] org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@47e235d2; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@47e235d2; line: 1, column: 1] at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:228) at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.read(MappingJackson2HttpMessageConverter.java:220) at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:95) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:788) at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:773) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:553) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:514) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:457) at grails.plugins.rest.client.RestBuilder.invokeRestTemplate(RestBuilder.groovy:307) at grails.plugins.rest.client.RestBuilder.doRequestInternal(RestBuilder.groovy:280) at grails.plugins.rest.client.RestBuilder.doRequestInternal(RestBuilder.groovy:268) at grails.plugins.rest.client.RestBuilder.post(RestBuilder.groovy:154) at grails.plugins.rest.client.RestBuilder$post.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at itools.BackstageAPIService.getToken(BackstageAPIService.groovy:14) at itools.BackstageAPIService$getToken.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) at BootStrap$_closure1.doCall(BootStrap.groovy:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1081) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.Closure.call(Closure.java:423) at groovy.lang.Closure.call(Closure.java:417) at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:327) at grails.util.Environment.executeForEnvironment(Environment.java:320) at grails.util.Environment.executeForCurrentEnvironment(Environment.java:296) at org.codehaus.groovy.grails.commons.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:60) at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:78) at org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener.initWebApplicationContext(GrailsContextLoaderListener.java:110) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4992) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5490) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@47e235d2; line: 1, column: 1] at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164) at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:749) at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:59) at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:12) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2206) at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.readJavaType(MappingJackson2HttpMessageConverter.java:225) ... 52 more

@zyro23 Note that when I remove the plugin the application starts successfully. Any help would be appreciated. Thanks, Yasmani

zyro23 commented 7 years ago

using v1.1.0? if not, try 1.1.0.

please note that the 1.x lines of the plugin are basically not supported anymore and i think the same is true for grails-2.4.x (2.5.x being the last supported grails-2 line, if that is actually still supported, not sure..).

otherwise, only thing that i can imagine is a conflict with the jackson-databind dependency (2.4.1.3) the plugin defines.

ref. https://github.com/zyro23/grails-spring-websocket/blob/v1.1.0/grails-app/conf/BuildConfig.groovy#L37

in your BuildConfig.groovy, try:

plugins {
    compile(":spring-websocket:1.1.0") {
        excludes "jackson-databind"
    }
}

but then you need to make sure that the jackson version you are using works with the websocket plugin.

yasmani16 commented 7 years ago

@zyro23 yes there was a conflict with jackson and rest-client-builder. That resolved the issue! Thanks for your help