You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by daya airody <da...@partnertap.com> on 2018/08/07 18:09:05 UTC

values retrieved from the cache are wrapped with JdkDynamicAopProxy while using springboot and JCache

Values retrieved from cache are wrapped with JdkDynamicAopProxy.  This throws
below NPEs

-----------
java.lang.NullPointerException: null
	at
org.springframework.aop.framework.AdvisedSupport.getInterceptorsAndDynamicInterceptionAdvice(AdvisedSupport.java:481)
	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:197)
	at com.sun.proxy.$Proxy255.getEmailAddress(Unknown Source)
	at
com.partnertap.analytics.controller.AdminCannedController.getAllReps(AdminCannedController.java:51)

---------------------------
I don't understand why cached values should be wrapped with proxies.
JdkDynamicAopProxy uses methodCache, which is null when the value is
retrieved from the cache.

This is where I am caching the java method
--------------------
	@CacheResult(cacheName = "cannedReports")
	public List<ReportsRepDetailsInterface> getAllReps(@CacheKey String
managerId) {
---------------------
In the object calling above method, I am trying to print, but getting NPE
instead.

--------------------------------
        List<ReportsRepDetailsInterface> allReps =
reportsService.getAllReps(managerId);
        for (ReportsRepDetailsInterface repDetail : allReps) {
            logger.info("email->", repDetail.getEmailAddress());
        }
---------------------

please help.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: values retrieved from the cache are wrapped with JdkDynamicAopProxy while using springboot and JCache

Posted by daya airody <da...@partnertap.com>.
Thanks Ivan. 

If methodCache is marked as transient, proxied objects are not meant to be
cached. Since this object is returned by spring JPA, hibernate second level
caching might be enough. Looks like we should not cache JPA returned objects
at method level.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: values retrieved from the cache are wrapped with JdkDynamicAopProxy while using springboot and JCache

Posted by Павлухин Иван <vo...@gmail.com>.
Hi daya,

Yes it is a serialization issue. Field AdvisedSupport.methodCache is marked
transient and method readObject which should initialize this field on
deserialization is not called. So, it has value null and NPE is thrown. I
am not sure whether it is expected behavior or not.
Also, it does not look very nice for me that such proxy is stored into
cache. Perhaps it is better to store simple Java objects, like
ReportsRepDetails in your example.

2018-08-14 19:21 GMT+03:00 ipavlukhin <vo...@gmail.com>:

> Hi daya,
>
> Sorry for delay. I hope I will have a minute tomorrow to check this case.
>
>
>
> On 13.08.2018 15:04, daya airody wrote:
>
>> HI Ivan,
>>
>> I have uploaded a simple spring application reproducing the issue at below
>> link:
>>
>> https://github.com/daya-airody/ignite-caching
>>
>> When I use ConcurrentMapCache to cache results from spring JPA native
>> query,
>> I am able to retrieve it correctly. However, once I enable ignite and
>> JCache, I run into proxy issues. Looks like I am hitting some
>> serialization
>> problem,
>>
>> Please review my code and help me troubleshoot this issue.
>>
>>
>> thanks in advance,
>>
>> --daya--
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>
>


-- 
Best regards,
Ivan Pavlukhin

Re: values retrieved from the cache are wrapped with JdkDynamicAopProxy while using springboot and JCache

Posted by ipavlukhin <vo...@gmail.com>.
Hi daya,

Sorry for delay. I hope I will have a minute tomorrow to check this case.


On 13.08.2018 15:04, daya airody wrote:
> HI Ivan,
>
> I have uploaded a simple spring application reproducing the issue at below
> link:
>
> https://github.com/daya-airody/ignite-caching
>
> When I use ConcurrentMapCache to cache results from spring JPA native query,
> I am able to retrieve it correctly. However, once I enable ignite and
> JCache, I run into proxy issues. Looks like I am hitting some serialization
> problem,
>
> Please review my code and help me troubleshoot this issue.
>
>
> thanks in advance,
>
> --daya--
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: values retrieved from the cache are wrapped with JdkDynamicAopProxy while using springboot and JCache

Posted by daya airody <da...@partnertap.com>.
HI Ivan,

I have uploaded a simple spring application reproducing the issue at below
link:

https://github.com/daya-airody/ignite-caching

When I use ConcurrentMapCache to cache results from spring JPA native query,
I am able to retrieve it correctly. However, once I enable ignite and
JCache, I run into proxy issues. Looks like I am hitting some serialization
problem,

Please review my code and help me troubleshoot this issue.


thanks in advance,

--daya--



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: values retrieved from the cache are wrapped with JdkDynamicAopProxy while using springboot and JCache

Posted by Павлухин Иван <vo...@gmail.com>.
Hi,

Looks like Spring itself wraps result into proxy. If you could provide a
reproducer it will help to find a reason faster.

2018-08-07 21:09 GMT+03:00 daya airody <da...@partnertap.com>:

> Values retrieved from cache are wrapped with JdkDynamicAopProxy.  This
> throws
> below NPEs
>
> -----------
> java.lang.NullPointerException: null
>         at
> org.springframework.aop.framework.AdvisedSupport.
> getInterceptorsAndDynamicInterceptionAdvice(AdvisedSupport.java:481)
>         at
> org.springframework.aop.framework.JdkDynamicAopProxy.
> invoke(JdkDynamicAopProxy.java:197)
>         at com.sun.proxy.$Proxy255.getEmailAddress(Unknown Source)
>         at
> com.partnertap.analytics.controller.AdminCannedController.getAllReps(
> AdminCannedController.java:51)
>
> ---------------------------
> I don't understand why cached values should be wrapped with proxies.
> JdkDynamicAopProxy uses methodCache, which is null when the value is
> retrieved from the cache.
>
> This is where I am caching the java method
> --------------------
>         @CacheResult(cacheName = "cannedReports")
>         public List<ReportsRepDetailsInterface> getAllReps(@CacheKey
> String
> managerId) {
> ---------------------
> In the object calling above method, I am trying to print, but getting NPE
> instead.
>
> --------------------------------
>         List<ReportsRepDetailsInterface> allReps =
> reportsService.getAllReps(managerId);
>         for (ReportsRepDetailsInterface repDetail : allReps) {
>             logger.info("email->", repDetail.getEmailAddress());
>         }
> ---------------------
>
> please help.
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Ivan Pavlukhin