I managed to resolve this by using the @SpringResource annotation like below 
(this was not required in Ignite 2.7.6),

@SpringResource(resourceName = "dataSource")
transient DataSource dataSource;

Thanks

Yohan

From: Yohan Fernando
Sent: 22 July 2020 17:14
To: '[email protected]' <[email protected]>
Subject: RE: Change in CacheStore Serialization from 2.7.6 to 2.8.x breaks 
Spring Injected dataSource

Hi all,

I have created a test project to reproduce this issue.

Running the project (Run.java)  using Ignite 2.8.1 produces the following 
error. Under 2.7.6 no such error occurs.

Exception in thread "main" javax.cache.integration.CacheLoaderException: 
java.lang.NullPointerException
                at 
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadCache(GridCacheStoreManagerAdapter.java:545)
                at 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter.localLoadCache(GridDhtCacheAdapter.java:636)
                at 
org.apache.ignite.internal.processors.cache.GridCacheProxyImpl.localLoadCache(GridCacheProxyImpl.java:226)
                at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob.localExecute(GridCacheAdapter.java:6052)
                at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJobV2.localExecute(GridCacheAdapter.java:6101)
                at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter$TopologyVersionAwareJob.execute(GridCacheAdapter.java:6735)
                at 
org.apache.ignite.compute.ComputeJobAdapter.call(ComputeJobAdapter.java:131)
                at 
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.execute(GridClosureProcessor.java:1855)
                at 
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:596)
                at 
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:7005)
                at 
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:590)
                at 
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:519)
                at 
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
                at 
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1293)
                at 
org.apache.ignite.internal.processors.task.GridTaskWorker.sendRequest(GridTaskWorker.java:1429)
                at 
org.apache.ignite.internal.processors.task.GridTaskWorker.processMappedJobs(GridTaskWorker.java:664)
                at 
org.apache.ignite.internal.processors.task.GridTaskWorker.body(GridTaskWorker.java:536)
                at 
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120)
                at 
org.apache.ignite.internal.processors.task.GridTaskProcessor.startTask(GridTaskProcessor.java:829)
                at 
org.apache.ignite.internal.processors.task.GridTaskProcessor.execute(GridTaskProcessor.java:497)
                at 
org.apache.ignite.internal.processors.closure.GridClosureProcessor.callAsync(GridClosureProcessor.java:449)
                at 
org.apache.ignite.internal.processors.closure.GridClosureProcessor.callAsync(GridClosureProcessor.java:420)
                at 
org.apache.ignite.internal.processors.closure.GridClosureProcessor.callAsync(GridClosureProcessor.java:404)
                at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter.globalLoadCacheAsync(GridCacheAdapter.java:4020)
                at 
org.apache.ignite.internal.processors.cache.GridCacheAdapter.globalLoadCache(GridCacheAdapter.java:3993)
                at 
org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.loadCache(IgniteCacheProxyImpl.java:387)
                at 
org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.loadCache(GatewayProtectedCacheProxy.java:311)
                at com.example.Run.main(Run.java:13)
Caused by: java.lang.NullPointerException
                at 
com.example.TraderCacheStore.loadCache(TraderCacheStore.java:26)
                at 
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter.loadCache(GridCacheStoreManagerAdapter.java:519)
                ... 27 more

Please let me know if you have any questions.

Thanks

Yohan
From: Yohan Fernando
Sent: 21 July 2020 16:13
To: '[email protected]' 
<[email protected]<mailto:[email protected]>>
Subject: Change in CacheStore Serialization from 2.7.6 to 2.8.x breaks Spring 
Injected dataSource

Hello All,

We are migrating from Ignite 2.7.6 to 2.8.1 and have hit an issue where 
CacheStore implementations that include Spring injected DataSource objects, 
these datasources turn out to be null. After investigation, it appears that 
there is a change in behaviour under Ignite 2.8.x where it seems like the 
CacheStore is Serialized and therefore loose the injected Spring references. 
This was not the case with 2.7.6 as the transient DataSource did not loose it's 
injected value in that version.

I have tried to make the CacheStore implement ApplicationContextAware, but it 
hasn't helped as the Spring context is not re-initialized post serialization.

Has anyone come across this and figured out a way to resolve this?

Thanks

Yohan

_________________________________________________________

This email, its contents, and any attachments transmitted with it are intended 
only for the addressee(s) and may be confidential and legally privileged. We do 
not waive any confidentiality by misdelivery. If you have received this email 
in error, please notify the sender immediately and delete it. You should not 
copy it, forward it or otherwise use the contents, attachments or information 
in any way. Any liability for viruses is excluded to the fullest extent 
permitted by law.

Tudor Capital Europe LLP (TCE) is authorised and regulated by The Financial 
Conduct Authority (the FCA). TCE is registered as a limited liability 
partnership in England and Wales No: OC340673 with its registered office at 10 
New Burlington Street, London, W1S 3BE, United Kingdom

Reply via email to