FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
316 stars 136 forks source link

Type 'com/fasterxml/jackson/dataformat/smile/SmileFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/JsonFactory' (from method signature) #233

Closed huxiaozheng closed 3 years ago

huxiaozheng commented 3 years ago

I encounter a problem when i run my project. It seems a jackson's problem, here is output. My jackson-core ,jackson-dataformat-smile,.......verion is 2.10.0 and spring'version is 5.2.9 . Anyone can give me some advice,i will appreciate.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Constructor threw exception; nested exception is java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    org/springframework/http/converter/json/Jackson2ObjectMapperBuilder$SmileFactoryInitializer.create()Lcom/fasterxml/jackson/core/JsonFactory; @7: areturn
  Reason:
    Type 'com/fasterxml/jackson/dataformat/smile/SmileFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/JsonFactory' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'org/springframework/http/converter/json/Jackson2ObjectMapperBuilder$SmileFactoryInitializer' }
    stack: { 'com/fasterxml/jackson/dataformat/smile/SmileFactory' }
  Bytecode:
    0x0000000: bb00 0359 b700 04b0      
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Constructor threw exception; nested exception is java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    org/springframework/http/converter/json/Jackson2ObjectMapperBuilder$SmileFactoryInitializer.create()Lcom/fasterxml/jackson/core/JsonFactory; @7: areturn
  Reason:
    Type 'com/fasterxml/jackson/dataformat/smile/SmileFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/JsonFactory' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'org/springframework/http/converter/json/Jackson2ObjectMapperBuilder$SmileFactoryInitializer' }
    stack: { 'com/fasterxml/jackson/dataformat/smile/SmileFactory' }
  Bytecode:
    0x0000000: bb00 0359 b700 04b0                    

    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:217)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1310)
    ... 31 more
Caused by: java.lang.VerifyError: Bad return type
Exception Details:
  Location:
    org/springframework/http/converter/json/Jackson2ObjectMapperBuilder$SmileFactoryInitializer.create()Lcom/fasterxml/jackson/core/JsonFactory; @7: areturn
  Reason:
    Type 'com/fasterxml/jackson/dataformat/smile/SmileFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/JsonFactory' (from method signature)
  Current Frame:
    bci: @7
    flags: { }
    locals: { 'org/springframework/http/converter/json/Jackson2ObjectMapperBuilder$SmileFactoryInitializer' }
    stack: { 'com/fasterxml/jackson/dataformat/smile/SmileFactory' }
  Bytecode:
    0x0000000: bb00 0359 b700 04b0                    

    at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.smile(Jackson2ObjectMapperBuilder.java:868)
    at org.springframework.http.converter.smile.MappingJackson2SmileHttpMessageConverter.<init>(MappingJackson2SmileHttpMessageConverter.java:50)
    at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:90)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.<init>(RequestMappingHandlerAdapter.java:204)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:204)
    ... 33 more
cowtowncoder commented 3 years ago

There are a few problems here:

  1. I don't see why this would be specific for Jackson XML format module?
  2. Version 2.10.0 is old -- you should at very least upgrade to latest 2.10.x patch, 2.10.5
  3. This may well be Spring issue as it seems Jackson is accessed using Spring framework

I will first move this to right repo, but I don't know if there is much Jackson project can do -- I would suggest:

  1. Upgrade all Jackson dependencies to 2.10.5
  2. Make sure all Jackson components have same version (at least same minor version, 2.10.x)
  3. Try to see if Spring community could help

If none of these help, we would need a reproduction -- ideally unit test -- that does not rely on external frameworks like Spring.

cowtowncoder commented 3 years ago

I suspect this is more related to Spring, and without a test case there isn't much we can do. May be reopened with a test case but closing for now.