gaojunda / simple-spring-memcached

Automatically exported from code.google.com/p/simple-spring-memcached
MIT License
0 stars 0 forks source link

Integration of ssm with mvc spring application throws exception with jackson 1.7.1 #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Follow the integration steps detailed here 
http://code.google.com/p/simple-spring-memcached/ with a spring mvc web 
application configured to use jackson 1.7.1. Just the configuration steps are 
required, not the annotation.
2. Build an deploy to tomcat3.

What is the expected output? What do you see instead?

Expected output is nothing in addition to the standard output from tomcat 
during deployment.

Actual output contains...

Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'defaultMemcachedClient' defined in file 
[C:\dev\ffiq-portal\FieldForceIQ\target\FieldForceIQ\WEB-INF\classes\META-INF\sp
ring\applicationContext.xml]: Instantiation of bean failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Could not instantiate 
bean class [com.google.code.ssm.CacheFactory]: Constructor threw exception; 
nested exception is java.lang.NoSuchFieldError: REQUIRE_SETTERS_FOR_GETTERS
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:767)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:698)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:519)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:319)
    at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:833)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    ... 108 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not 
instantiate bean class [com.google.code.ssm.CacheFactory]: Constructor threw 
exception; nested exception is java.lang.NoSuchFieldError: 
REQUIRE_SETTERS_FOR_GETTERS
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
    ... 118 more
Caused by: java.lang.NoSuchFieldError: REQUIRE_SETTERS_FOR_GETTERS
    at com.google.code.ssm.mapper.JsonObjectMapper.<init>(JsonObjectMapper.java:50)
    at com.google.code.ssm.CacheFactory.<init>(CacheFactory.java:89)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
    ... 120 more

This causes a bean creation exception further up the chain.

What version of the product are you using? On what operating system?

Spring framework 3.1.1.RELEASE
Jackson 1.71
Tomcat 7.0.27
JDK/JRE 7
Windows 7

Please provide any additional information below.

Changing the version of jackson from 1.7.1 to 1.9.10 resolved the issue for us.

Regards,

Mark

Original issue reported on code.google.com by mark.hib...@gmail.com on 5 Dec 2012 at 5:55

GoogleCodeExporter commented 8 years ago
Thanks for creating the issue

Original comment by ragno...@gmail.com on 5 Dec 2012 at 9:50

GoogleCodeExporter commented 8 years ago
Added initializeTranscoders property to CacheFactory by default set to true. If 
set false transcoders won't be created automatically (including json 
transcoder) so jackson classes (ObjectMapper) won't be initialized.
Code in trunk.

Original comment by ragno...@gmail.com on 26 Mar 2013 at 8:45

GoogleCodeExporter commented 8 years ago

Original comment by ragno...@gmail.com on 24 Jun 2013 at 8:27

GoogleCodeExporter commented 8 years ago
Included in release 3.2.0

Original comment by ragno...@gmail.com on 27 Jun 2013 at 7:58

GoogleCodeExporter commented 8 years ago
Could you please elaborate on #2 comment. I didn't understand the purpose. I am 
using 3.2.0 version and facing the same problem. Adding initializeTranscoders 
property by default set to false prevents the error, though I am not sure of 
it's repercussions.

Original comment by meetmick...@gmail.com on 9 Jul 2013 at 1:43

GoogleCodeExporter commented 8 years ago
In 3.2.0 a new property was added to CacheFactory: initializeTranscoders. When 
it set to false (by default it is true) then SSM will not try to create 
automatically any Jackson objects. If you use only java serialization to store 
cached object (it's by default) then you don't need Jackson beans in SSM and 
can disable it. Disabling also allow you to use in your project other Jackson 
version than required by SSM. Previously even if JSON serialization in SSM 
wasn't used some Jackson objects were created at the startup and specific 
Jackson version on the classpath was required.

Original comment by ragno...@gmail.com on 10 Jul 2013 at 4:50