Error "Failed to create PDX instance from json" caused by CacheClosedException in VMware GemFire
search cancel

Error "Failed to create PDX instance from json" caused by CacheClosedException in VMware GemFire

book

Article ID: 293996

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

This is applicable to all versions of VMware GemFire.

After configuring PDX, accessing the PDX entries works only once. Subsequent calls fail with the error: "Failed to create PDX instance from json".

The stack trace shows the following:

Caused by: org.apache.geode.cache.CacheClosedException: Client pools have been closed so the PDX type registry is not available.


Resolution

The CacheClosedException indicates that the caching system has been closed. This exception can be thrown from almost any method related to regions or the cache after the cache has been closed.

Here are some recommendations to resolve this issue:
 

  • Please make sure that the client is connected to a cluster, through either a locator or server ports.
  • When using the LOCAL region, you have to make a call to initialize the default pool before creating the PdxInstance.
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(host, port); // Server end point
ClientCache cache = getClientCache(cf);
cache.getDefaultPool(); // Initialize the pool
  • Please make sure that the ClientCacheFactory() is called only once. If the ClientCacheFactory() is called multiple times, then loading and accessing the data the second time will fail with “Failed to create PDX instance from json”.