Using a custom Infinispan cache configuration

Out of the box, Inifinispan uses a default cache configuration. To set a custom configuration, create an Infinispan XML configuration file and set the PATH to it in your web.xml file, under the key infinispan.config.

The infinispan configuration file is dictated by the Init Servlet which contains the name and the path where the configuration is stored:


   <!-- Specify your cache configuration file -->

. . . . .

As it is, drop the following infinispan.xml file into WEB-INF/classes of your application:


   <namedCache name="cacheX" />


So now you can reference cacheX from your RESTful clients.

Last minute addition:

I'm adding a pure javascript code (no jQuery) for interacting with REStful services, you can have a try on it if you like:


var url = "http://localhost:8080/infinispan/rest/cacheX/bucket1";
var representationOfDesiredState = "Adding this to the cache";

var client = new XMLHttpRequest();"PUT", url, false);

client.setRequestHeader("Content-Type", "text/plain");


if (client.status == 200)
 alert("The request succeeded!\n\nThe response representation was:\n\n" + client.responseText)
 alert("The request did not succeed!\n\nThe response status was: " + client.status + " " + client.statusText + ".");



Related articles available on

Getting Started with Infinispan - Part 1

This tutorial has been updated to work with the lastes Infinispan

Infinispan tutorial part 2

In the first tutorial we have covered some basic concepts about I

Develop a clustered application with Infinispan Data Grid

In this tutorial we will use Infinispan Data Grid Platform to sto

Using Infinispan with WildFly

The Infinispan subsystem provides caching support for HA services

Using Infinispan Query API

Applications using a NoSQL storage often need to query data using

Monitoring WildFly's Infinispan caches

In this tutorial we will learn how to monitor the Embedded Infini