NullPointerException: Null values are not supported! thrown when using Spring @Cacheable
sannsims Dec 9, 2012 12:27 AMHello everyone! I'm working on a Infinispan Cache (5.1.6) demo which we want to consider implementing in a project. I'm annotating my methods using Spring 3.1.RC1 annotation: @Cacheable and @CacheEvict. Thus far, all I done is declaratively configured cache. There haven't been any errors when I invoke a method to get all data from the database. However, when I tried to insert data, I get the following error:
java.lang.NullPointerException: Null values are not supported!
Below is the output from the logs of the object I'm trying to persist to the database which none of the values are null.
2012-12-08 22:17:43,226 INFO [STDOUT] (http-127.0.0.1-8280-1) Executing PetDAO insertPet() ID: 12 Name: Lassie Origin: The Lassie Show Type: Dog
Here's the code from the data broker:
@Cacheable( value = "pets" ) public List<Pet> getAllPets() //works fine { System.out.println( "Executing PetDAO getAllPets()" ); List<Pet> allPets = jdbcTemplate.query( "select * from pets order by id", new PetMapper() ); return allPets; } @Cacheable( value = "pets" ) public void insertPet( Pet pet ) //problem when invoking this method { System.out.println( "Executing PetDAO insertPet() " + pet.toString() ); jdbcTemplate.update( "insert into pets ( name, origin, id, type ) " + "values ( ?, ?, ?, ? )", pet.getName(), pet.getOrigin(), pet.getId(), pet.getType() ); }
Note: insertPet will only work without the @Cacheable annotation???
<namedCache name="pets"> <eviction maxEntries="10" strategy="LRU" /> <expiration wakeUpInterval="500" lifespan="60000" maxIdle="1000" /> </namedCache>
Below is the error from the Rest Server. Internet search on this error came up empty. If anyone has a suggestion/solution on how to resolve this error or even how to troubleshoot it, I would appreciate it! I'm stumped?!
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) java.lang.NullPointerException: Null values are not supported!
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.infinispan.CacheImpl.assertKeyValueNotNull(CacheImpl.java:203)
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.infinispan.CacheImpl.put(CacheImpl.java:699)
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.infinispan.CacheImpl.put(CacheImpl.java:694)
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.infinispan.CacheSupport.put(CacheSupport.java:53)
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.infinispan.spring.provider.SpringCache.put(SpringCache.java:83)
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:232)
2012-12-08 22:17:43,413 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at com.infinispan.rest.dao.PetDAO$$EnhancerByCGLIB$$de9d088a_2.insertPet(<generated>)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at com.infinispan.rest.services.PetBroker.addPet(PetBroker.java:34)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at com.infinispan.rest.services.PetService.addPet(PetService.java:40)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at java.lang.reflect.Method.invoke(Method.java:597)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
2012-12-08 22:17:43,429 ERROR [STDERR] (http-127.0.0.1-8280-1) at java.lang.Thread.run(Thread.java:662)
Thanks for reading my post!