You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Rajarshi Pain <ra...@gmail.com> on 2018/01/04 15:17:37 UTC
java.lang.IllegalStateException: Cache has been closed:
Hi,
I am using Ignite 2.3 for my application. But got Cache closed exception
while running.
This is a multi threaded application through testing on single thread. it
will load the reference number from database to cache during startup and
while processing a message, it will check if that particular reference
number is present or not on that cache.
if there is no entry it will add refernce_number-approved else
refernce_number-rejected.
I was testing with 2000 message but for some of the message during the
validation it's throwing *Cache has been closed *exception.
while tested the same code with 10 messages didnt get any exception.
couldnt figure it out why I am getting this exception while the cache is
active ?
*java.lang.IllegalStateException: Cache has been closed:
ReferenceStatusCache*
at
org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.checkProxyIsValid(GatewayProtectedCacheProxy.java:1639)
at
org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.onEnter(GatewayProtectedCacheProxy.java:1654)
at
org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.put(GatewayProtectedCacheProxy.java:869)
at
sample.example.ProcessingConsumerThread.populateMsgObj(ProcessingConsumerThread.java:232)
at
sample.example.ProcessingConsumerThread..run(ProcessingConsumerThread.java:164)
at
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4.execute(GridClosureProcessor.java:1944)
at
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:566)
at
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6631)
at
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:560)
at
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:489)
at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
--
Regards,
Raj
Re: java.lang.IllegalStateException: Cache has been closed:
Posted by Alexey Popov <ta...@gmail.com>.
Hi Raj,
IgniteCache implements AutoCloseable interface. [1]
You can't access it once IgniteCache.close() is called (implicitly via
try-with-resource or explicitly).
[1]
https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
Thanks,
Alexey
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: java.lang.IllegalStateException: Cache has been closed:
Posted by Rajarshi Pain <ra...@gmail.com>.
thanks Denis.
Can you please tell me how a try-with-resources works in Ignite ?
On Thu, Jan 4, 2018 at 8:57 PM, Denis Mekhanikov <dm...@gmail.com>
wrote:
> Hi Rajarshi!
>
> Well, it must be, that you are actually closing the cache.
> Check, that you didn't put cache creation into a try-with-resources.
> When *IgniteCache.close()* is called, then cache is destroyed.
>
> Denis
>
> чт, 4 янв. 2018 г. в 18:17, Rajarshi Pain <ra...@gmail.com>:
>
>> Hi,
>>
>> I am using Ignite 2.3 for my application. But got Cache closed exception
>> while running.
>>
>> This is a multi threaded application through testing on single thread. it
>> will load the reference number from database to cache during startup and
>> while processing a message, it will check if that particular reference
>> number is present or not on that cache.
>>
>> if there is no entry it will add refernce_number-approved else
>> refernce_number-rejected.
>>
>> I was testing with 2000 message but for some of the message during the
>> validation it's throwing *Cache has been closed *exception.
>>
>> while tested the same code with 10 messages didnt get any exception.
>>
>> couldnt figure it out why I am getting this exception while the cache is
>> active ?
>>
>> *java.lang.IllegalStateException: Cache has been closed:
>> ReferenceStatusCache*
>> at org.apache.ignite.internal.processors.cache.
>> GatewayProtectedCacheProxy.checkProxyIsValid(GatewayProtectedCacheProxy.
>> java:1639)
>> at org.apache.ignite.internal.processors.cache.
>> GatewayProtectedCacheProxy.onEnter(GatewayProtectedCacheProxy.java:1654)
>> at org.apache.ignite.internal.processors.cache.
>> GatewayProtectedCacheProxy.put(GatewayProtectedCacheProxy.java:869)
>> at sample.example.ProcessingConsumerThread.populateMsgObj(
>> ProcessingConsumerThread.java:232)
>> at sample.example.ProcessingConsumerThread..run(
>> ProcessingConsumerThread.java:164)
>> at org.apache.ignite.internal.processors.closure.
>> GridClosureProcessor$C4.execute(GridClosureProcessor.java:1944)
>> at org.apache.ignite.internal.processors.job.GridJobWorker$
>> 2.call(GridJobWorker.java:566)
>> at org.apache.ignite.internal.util.IgniteUtils.
>> wrapThreadLoader(IgniteUtils.java:6631)
>> at org.apache.ignite.internal.processors.job.GridJobWorker.
>> execute0(GridJobWorker.java:560)
>> at org.apache.ignite.internal.processors.job.GridJobWorker.
>> body(GridJobWorker.java:489)
>> at org.apache.ignite.internal.util.worker.GridWorker.run(
>> GridWorker.java:110)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(
>> ThreadPoolExecutor.java:1149)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(
>> ThreadPoolExecutor.java:624)
>> at java.lang.Thread.run(Thread.java:748)
>>
>> --
>> Regards,
>> Raj
>>
>
--
Regards,
Rajarshi Pain
Re: java.lang.IllegalStateException: Cache has been closed:
Posted by Denis Mekhanikov <dm...@gmail.com>.
Hi Rajarshi!
Well, it must be, that you are actually closing the cache.
Check, that you didn't put cache creation into a try-with-resources.
When *IgniteCache.close()* is called, then cache is destroyed.
Denis
чт, 4 янв. 2018 г. в 18:17, Rajarshi Pain <ra...@gmail.com>:
> Hi,
>
> I am using Ignite 2.3 for my application. But got Cache closed exception
> while running.
>
> This is a multi threaded application through testing on single thread. it
> will load the reference number from database to cache during startup and
> while processing a message, it will check if that particular reference
> number is present or not on that cache.
>
> if there is no entry it will add refernce_number-approved else
> refernce_number-rejected.
>
> I was testing with 2000 message but for some of the message during the
> validation it's throwing *Cache has been closed *exception.
>
> while tested the same code with 10 messages didnt get any exception.
>
> couldnt figure it out why I am getting this exception while the cache is
> active ?
>
> *java.lang.IllegalStateException: Cache has been closed:
> ReferenceStatusCache*
> at
> org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.checkProxyIsValid(GatewayProtectedCacheProxy.java:1639)
> at
> org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.onEnter(GatewayProtectedCacheProxy.java:1654)
> at
> org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.put(GatewayProtectedCacheProxy.java:869)
> at
> sample.example.ProcessingConsumerThread.populateMsgObj(ProcessingConsumerThread.java:232)
> at
> sample.example.ProcessingConsumerThread..run(ProcessingConsumerThread.java:164)
> at
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4.execute(GridClosureProcessor.java:1944)
> at
> org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:566)
> at
> org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6631)
> at
> org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:560)
> at
> org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:489)
> at
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
>
> --
> Regards,
> Raj
>