Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

在springmvc-4.2.5使用fastjson-1.2.10 出现关于MediaType异常 #577

Closed
dounine opened this issue Apr 24, 2016 · 5 comments
Closed

在springmvc-4.2.5使用fastjson-1.2.10 出现关于MediaType异常 #577

dounine opened this issue Apr 24, 2016 · 5 comments

Comments

@dounine
Copy link

dounine commented Apr 24, 2016

使用springmvc-4.2.5与servlet-3.1&fastjson-1.2.10
java注解code如下

public class MvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        // alibaba fastJson java config
        FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
        List<MediaType> mediaTypes = new ArrayList<>(1);
        mediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
        fastJsonHttpMessageConverter.setSupportedMediaTypes(mediaTypes);
        fastJsonHttpMessageConverter.setFeatures(SerializerFeature.DisableCircularReferenceDetect);

        converters.add(fastJsonHttpMessageConverter);

异常信息如下:

java.lang.AbstractMethodError: com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter.canWrite(Ljava/lang/reflect/Type;Ljava/lang/Class;Lorg/springframework/http/MediaType;)Z
    at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.getProducibleMediaTypes(AbstractMessageConverterMethodProcessor.java:308)
    at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:175)
    at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:153)
    at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:165)
    at org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:80)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
@wenshao
Copy link
Member

wenshao commented Apr 24, 2016

@VictorZeng 帮忙看一下

@VictorZeng
Copy link
Contributor

This issue as same as #574

@VictorZeng
Copy link
Contributor

fixed in #579

wenshao added a commit that referenced this issue Apr 25, 2016
@bwzhang2011
Copy link

@wenshao, 是否1.2.11版本会尽快发布(修复上述)

@wenshao wenshao closed this as completed May 2, 2016
@wenshao
Copy link
Member

wenshao commented May 2, 2016

1.2.1发布了,问题已经解决。请使用新版本 https://github.com/alibaba/fastjson/releases/tag/1.2.11_release

asa1997 pushed a commit to Be-Secure/fastjson that referenced this issue Feb 8, 2023
asa1997 pushed a commit to Be-Secure/fastjson that referenced this issue Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants