spring 和 jackson 中关于 Jrebel build 的错误
The error about Jrebel build in spring and jackson
今天,我在 spring 中发生了有关 jrebel 构建的错误。提出请求时,发现错误:
2016-05-08 15:53:19 JRebel-SDK-CBP: ERROR Class 'com.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap' could not be processed by org.zeroturnaround.jrebel.jackson2.cbp.ReadOnlyClassToSerializerMap2CBP@org.apache.catalina.loader.WebappClassLoader@aafbe07: org.zeroturnaround.bundled.javassist.NotFoundException: field: _map in com.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap
at org.zeroturnaround.bundled.javassist.CtClassType.checkGetField(SourceFile:920)
at org.zeroturnaround.bundled.javassist.CtClassType.getDeclaredField(SourceFile:969)
at org.zeroturnaround.bundled.javassist.CtClassType.getDeclaredField(SourceFile:964)
at org.zeroturnaround.jrebel.jackson2.cbp.ReadOnlyClassToSerializerMap2CBP.process(ReadOnlyClassToSerializerMap2CBP.java:33)
at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:66)
at com.zeroturnaround.javarebel.asZ.a(SourceFile:257)
at com.zeroturnaround.javarebel.asZ.a(SourceFile:246)
at com.zeroturnaround.javarebel.asZ.a(SourceFile:230)
at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:31)
at com.zeroturnaround.javarebel.asf.transform(SourceFile:84)
at java.lang.ClassLoader.defineClass(ClassLoader.java)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access0(URLClassLoader.java:71)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.net.URLClassLoader.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1189)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at com.fasterxml.jackson.databind.ser.SerializerCache.getReadOnlyLookupMap(SerializerCache.java:50)
at com.fasterxml.jackson.databind.SerializerProvider.<init>(SerializerProvider.java:232)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.<init>(DefaultSerializerProvider.java:61)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.<init>(DefaultSerializerProvider.java:595)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.createInstance(DefaultSerializerProvider.java:609)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.createInstance(DefaultSerializerProvider.java:588)
at com.fasterxml.jackson.databind.ObjectMapper._serializerProvider(ObjectMapper.java:3587)
at com.fasterxml.jackson.databind.ObjectMapper.canSerialize(ObjectMapper.java:2611)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canWrite(AbstractJackson2HttpMessageConverter.java:165)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.getProducibleMediaTypes(AbstractMessageConverterMethodProcessor.java:204)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:122)
at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:144)
at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:71)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:128)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:781)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:171)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
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)
也许你的问题涉及杰克逊。所以我postjackson配置的代码:
@Bean
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
RequestMappingHandlerAdapter requestMappingHadler = new RequestMappingHandlerAdapter();
List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
messageConverters.add(jacksonConverter());
requestMappingHadler.setMessageConverters(messageConverters);
return requestMappingHadler;
}
@Bean
public MappingJackson2HttpMessageConverter jacksonConverter() {
MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
final Map<String, String> parameterMap = new HashMap<String, String>(4);
parameterMap.put("charset", "utf-8");
MediaType type = new MediaType("application","json", parameterMap);
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(type);
jacksonConverter.setSupportedMediaTypes(supportedMediaTypes);
return jacksonConverter;
}
当我发送请求时,服务器发送响应,并且returns一个json数据格式,会引用这个错误。
我该如何解决?
您使用的 JRebel 版本早于 6.1.2 和 jackson-databind 2.6.0+ 吗?在这种情况下,只需更新 JRebel 即可修复错误。
今天,我在 spring 中发生了有关 jrebel 构建的错误。提出请求时,发现错误:
2016-05-08 15:53:19 JRebel-SDK-CBP: ERROR Class 'com.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap' could not be processed by org.zeroturnaround.jrebel.jackson2.cbp.ReadOnlyClassToSerializerMap2CBP@org.apache.catalina.loader.WebappClassLoader@aafbe07: org.zeroturnaround.bundled.javassist.NotFoundException: field: _map in com.fasterxml.jackson.databind.ser.impl.ReadOnlyClassToSerializerMap
at org.zeroturnaround.bundled.javassist.CtClassType.checkGetField(SourceFile:920)
at org.zeroturnaround.bundled.javassist.CtClassType.getDeclaredField(SourceFile:969)
at org.zeroturnaround.bundled.javassist.CtClassType.getDeclaredField(SourceFile:964)
at org.zeroturnaround.jrebel.jackson2.cbp.ReadOnlyClassToSerializerMap2CBP.process(ReadOnlyClassToSerializerMap2CBP.java:33)
at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:66)
at com.zeroturnaround.javarebel.asZ.a(SourceFile:257)
at com.zeroturnaround.javarebel.asZ.a(SourceFile:246)
at com.zeroturnaround.javarebel.asZ.a(SourceFile:230)
at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:31)
at com.zeroturnaround.javarebel.asf.transform(SourceFile:84)
at java.lang.ClassLoader.defineClass(ClassLoader.java)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access0(URLClassLoader.java:71)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.net.URLClassLoader.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1189)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at com.fasterxml.jackson.databind.ser.SerializerCache.getReadOnlyLookupMap(SerializerCache.java:50)
at com.fasterxml.jackson.databind.SerializerProvider.<init>(SerializerProvider.java:232)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.<init>(DefaultSerializerProvider.java:61)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.<init>(DefaultSerializerProvider.java:595)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.createInstance(DefaultSerializerProvider.java:609)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider$Impl.createInstance(DefaultSerializerProvider.java:588)
at com.fasterxml.jackson.databind.ObjectMapper._serializerProvider(ObjectMapper.java:3587)
at com.fasterxml.jackson.databind.ObjectMapper.canSerialize(ObjectMapper.java:2611)
at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canWrite(AbstractJackson2HttpMessageConverter.java:165)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.getProducibleMediaTypes(AbstractMessageConverterMethodProcessor.java:204)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:122)
at org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor.handleReturnValue(HttpEntityMethodProcessor.java:144)
at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:71)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:128)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:781)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:171)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
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)
也许你的问题涉及杰克逊。所以我postjackson配置的代码:
@Bean
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
RequestMappingHandlerAdapter requestMappingHadler = new RequestMappingHandlerAdapter();
List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
messageConverters.add(jacksonConverter());
requestMappingHadler.setMessageConverters(messageConverters);
return requestMappingHadler;
}
@Bean
public MappingJackson2HttpMessageConverter jacksonConverter() {
MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
final Map<String, String> parameterMap = new HashMap<String, String>(4);
parameterMap.put("charset", "utf-8");
MediaType type = new MediaType("application","json", parameterMap);
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(type);
jacksonConverter.setSupportedMediaTypes(supportedMediaTypes);
return jacksonConverter;
}
当我发送请求时,服务器发送响应,并且returns一个json数据格式,会引用这个错误。 我该如何解决?
您使用的 JRebel 版本早于 6.1.2 和 jackson-databind 2.6.0+ 吗?在这种情况下,只需更新 JRebel 即可修复错误。