2 Replies Latest reply on Jul 21, 2014 7:28 AM by Edin A

    Nodes lost after server restart

    Edin A Newbie



      I've tried to implement modeshape into my application.

      For now the application is running, and I'am able to write the repository.

      BUT, if I stop the tomcat-server, and start it again, all nodes are lost !


      My environment: Tomcat, ModeShape 3.8.0.Final. ModeShape repo and engine, as member in a spring-service (org.springframework.stereotype.Service).


      I do start the engnie+repo, this way:



          public void initRepo()


              this.engine = new ModeShapeEngine();



              try {

                  RepositoryConfiguration config = RepositoryConfiguration.read("repository.json");

                  org.modeshape.common.collection.Problems problems = config.validate();

                  if (problems.hasErrors()) {

                      System.err.println("Problems with the configuration.");




                  this.repo = this.engine.deploy(config);




      Here is the content of the repository.json:



          "name" : "Iris Repository",

          "workspaces" : {

              "default" : "default",

              "predefined" : ["otherWorkspace"],

              "allowCreation" : true


          "security" : {

              "anonymous" : {

                  "roles" : ["readonly","readwrite","admin"],

                  "username" : "<anonymous>",

                  "useOnFailedLogin" : false



          "storage" : {

              "binaryStorage" : {

                  "type" : "file",

                  "directory" : "/home/myuser/repoFolder",

                  "minimumBinarySizeInBytes" : 40




          "node-types" : ["cnd/repoContent.cnd"]




      The infinspan-config : <infinispan/>



      Any suggestions ?

        • 1. Re: Nodes lost after server restart
          Adam McCormick Newbie

          You need to add some cache configurations to the storage section, which you don't have.  Without it Modeshape uses a default Infinispan configuration which is an in-memory cache.  Just having an infinispan.xml file on the classpath won't do.


          Add the following to your repository config json:

              "storage" : {
                  "cacheName" : "iris_repository",
                  "cacheConfiguration" : "infinispan.xml",
                  "transactionManagerLookup" = "org.infinispan.transaction.lookup.GenericTransactionManagerLookup",
                  "binaryStorage" : {
                      "type" : "file",
                      "directory" : "/home/myuser/repoFolder",
                      "minimumBinarySizeInBytes" : 40

          The above configures Modeshape to use the cache iris_repository (from the cacheName property) from the Infinispan configuration pointed to by the cacheConfiguration property.


          Here's an example infinispan.xml which uses the file system cache store to persist to disk.  Note the property "location" which is where the store will write to. I put it in a directory beside where you store your binaries (which is where I think you may have the confusion if you though that section was storing repository data. It's not. The binaryStorage section defines where property values will be stored if they are over the size configured, in your case > 40 bytes. This doesn't actually store any node/property information).

                 xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
              <namedCache name="iris_cache">
                 <transaction transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
                 <loaders passivation="false" shared="false" preload="false">
                    <loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="false" purgeOnStartup="false">
                          <!-- location where to store the data. -->
                          <property name="location" value="/home/myuser/repoData"/>
                       <async enabled="true" flushLockTimeout="15000" threadPoolSize="5"/>


          Checkout the docs for more info.  The above Infinispan config is basically the one from: ModeShape in Java applications - ModeShape 3 - Project Documentation Editor


          Hope this helps

          1 of 1 people found this helpful
          • 2. Re: Nodes lost after server restart
            Edin A Newbie

            Hello Adam,


            thank you for your helpful answer.

            I've already find out this, via try and error.


            ModeShape have good documentation, but in this case it is really rare.

            From my point of view, the documentation should state explicitly, that the data are lost form the REPO, when you do not use an infinspan config with "location"...

            This is the main feature of an repository, to find the data again, even after restart  


            Maybe it should be titled as serializer, and not 'only' as cache.


            Thank you very much, for the example.