spring boot - get java.lang.ArrayStoreException on Springboot and ehcache -
i have method calls webservice , same input arguments, want result cached. so, here did far: main class:
import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.boot.context.web.springbootservletinitializer; import org.springframework.cache.cachemanager; import org.springframework.cache.annotation.enablecaching; import org.springframework.cache.ehcache.ehcachecachemanager; import org.springframework.cache.ehcache.ehcachemanagerfactorybean; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.componentscan; import org.springframework.core.io.classpathresource; @enablecaching @componentscan @springbootapplication public class accserver extends springbootservletinitializer { @bean public cachemanager cachemanager() { return new ehcachecachemanager(ehcachecachemanager().getobject()); } @bean public ehcachemanagerfactorybean ehcachecachemanager() { ehcachemanagerfactorybean cmfb = new ehcachemanagerfactorybean(); cmfb.setconfiglocation(new classpathresource("ehcache.xml")); cmfb.setshared(true); return cmfb; } }
method cache:
import java.util.list; import org.springframework.cache.annotation.cacheable; import org.springframework.stereotype.service; @service public class someclass implements isomeclass { @override @cacheable("acc") public list<integer> trs() { return websrv.trs(); } }
ehcache.xml
<?xml version="1.0" encoding="utf-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="http://ehcache.org/ehcache.xsd" updatecheck="false"> <diskstore path="java.io.tmpdir" /> <cache name="acc" maxelementsinmemory="100" eternal="false" timetoidleseconds="120" timetoliveseconds="120" overflowtodisk="true" maxelementsondisk="10000000" diskpersistent="false" diskexpirythreadintervalseconds="120" memorystoreevictionpolicy="lru" /> </ehcache>
and get:
caused by: java.lang.arraystoreexception: sun.reflect.annotation.typenotpresentexceptionproxy @ sun.reflect.annotation.annotationparser.parseclassarray(unknown source) @ sun.reflect.annotation.annotationparser.parsearray(unknown source) @ sun.reflect.annotation.annotationparser.parsemembervalue(unknown source) @ sun.reflect.annotation.annotationparser.parseannotation2(unknown source) @ sun.reflect.annotation.annotationparser.parseannotations2(unknown source) @ sun.reflect.annotation.annotationparser.parseannotations(unknown source) @ java.lang.class.createannotationdata(unknown source) @ java.lang.class.annotationdata(unknown source) @ java.lang.class.createannotationdata(unknown source) @ java.lang.class.annotationdata(unknown source) @ java.lang.class.getannotation(unknown source) @ org.springframework.cache.annotation.springcacheannotationparser.getannotations(springcacheannotationparser.java:201) @ org.springframework.cache.annotation.springcacheannotationparser.parsecacheannotations(springcacheannotationparser.java:64) @ org.springframework.cache.annotation.springcacheannotationparser.parsecacheannotations(springcacheannotationparser.java:52) @ org.springframework.cache.annotation.annotationcacheoperationsource$1.getcacheoperations(annotationcacheoperationsource.java:113) @ org.springframework.cache.annotation.annotationcacheoperationsource.determinecacheoperations(annotationcacheoperationsource.java:142) @ org.springframework.cache.annotation.annotationcacheoperationsource.findcacheoperations(annotationcacheoperationsource.java:110) @ org.springframework.cache.interceptor.abstractfallbackcacheoperationsource.computecacheoperations(abstractfallbackcacheoperationsource.java:142) @ org.springframework.cache.interceptor.abstractfallbackcacheoperationsource.getcacheoperations(abstractfallbackcacheoperationsource.java:97) @ org.springframework.cache.interceptor.cacheoperationsourcepointcut.matches(cacheoperationsourcepointcut.java:39) @ org.springframework.aop.support.aoputils.canapply(aoputils.java:211) @ org.springframework.aop.support.aoputils.canapply(aoputils.java:248) @ org.springframework.aop.support.aoputils.findadvisorsthatcanapply(aoputils.java:280) @ org.springframework.aop.framework.autoproxy.abstractadvisorautoproxycreator.findadvisorsthatcanapply(abstractadvisorautoproxycreator.java:118) @ org.springframework.aop.framework.autoproxy.abstractadvisorautoproxycreator.findeligibleadvisors(abstractadvisorautoproxycreator.java:88) @ org.springframework.aop.framework.autoproxy.abstractadvisorautoproxycreator.getadvicesandadvisorsforbean(abstractadvisorautoproxycreator.java:69) @ org.springframework.aop.framework.autoproxy.abstractautoproxycreator.wrapifnecessary(abstractautoproxycreator.java:346) @ org.springframework.aop.framework.autoproxy.abstractautoproxycreator.postprocessafterinitialization(abstractautoproxycreator.java:298) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.applybeanpostprocessorsafterinitialization(abstractautowirecapablebeanfactory.java:422) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1583) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:545) ... 135 more
i use @cacheable("acc")
annotation method should cached result. answers appreciated.
the issue @cacheable
trs()
method (of @service
someclass
class) not returning list<integer>
object because of getting sun.reflect.annotation.typenotpresentexceptionproxy
exception.
you need ensure trs()
returning list<integer>
object.
Comments
Post a Comment