5 Replies Latest reply on Aug 3, 2014 10:17 PM by Nick Cavallo

    Errors while restoring the ModeShape repository

    vpeddireddi Newbie

      I'm trying to perform backup and restore operations using ModeShape API, running into some issues. Please find the details below, appreciate any inputs


      Cache configuration in standalone.xml

      <cache-container name="modeshape">

                      <local-cache name="cache_instance_1">

                          <transaction mode="NON_XA"/>

                          <eviction strategy="LIRS" max-entries="5000"/>

                          <string-keyed-jdbc-store datasource="java:/jdbc/modeshape" preload="false" passivation="false" purge="false">

                              <property name="databaseType">

                                  postgres

                              </property>

                              <property name="createTableOnStart">

                                  true

                              </property>

                              <string-keyed-table prefix="stringbased">

                                  <id-column name="id" type="VARCHAR(200)"/>

                                  <data-column name="data" type="BYTEA"/>

                                  <timestamp-column name="version" type="BIGINT"/>

                              </string-keyed-table>

                          </string-keyed-jdbc-store>

                      </local-cache>

      </cache-container>

      Repository backup code


      InitialContext initialContext = new InitialContext();

              Repository repo =  (Repository)initialContext.lookup("java:/jcr/repositoryName");

       

              Problems problems = null;

              Session session =  null;

       

              try {

                  session = (Session) repo.login("default");

                  RepositoryManager manager = session.getWorkspace().getRepositoryManager();

                  problems = manager.backupRepository(backupPath);

                 

       

                  if (problems.hasProblems()) {

                      throw new RepositoryException("Problems detected during backup");

                  }

       

              } catch (RepositoryException e) {

                  System.out.println("@@ BackupRepository : "+e);

                  if (problems != null && problems.hasProblems()) {

                      model.put("problems", problems);

                  }

       

                  // Delete the backup directory so we can never restore from it

                  backupPath.delete();

                  throw e;

              }finally{

                  if(session != null){

                      session.logout();

                  }

              }

       

      Restore code

      Session session = null;

              try {

                  InitialContext initialContext = new InitialContext();

       

                  Repository repo =  (Repository)initialContext.lookup("java:/jcr/repositoryName");

                  session = (Session) repo.login("default");

       

                  RepositoryManager manager = session.getWorkspace().getRepositoryManager();

                  Problems problems = manager.restoreRepository(backupPath);       

       

                  if (problems.hasProblems()) {

                      model.put("problems", problems);

                      return ResponseBodyStatus.ERROR.withResultOnModel(model);

                  }

              } catch (Exception e) {

                  // TODO Auto-generated catch block

                  //e.printStackTrace();

                  System.out.println("@@ RestoreRepositoryFromBackup : "+e);

              }finally{

                  if(session != null){

                      session.refresh(true);

                      session.logout();

                  }

              }

       

      ERROR Message

      javax.jcr.RepositoryException: The 'xyg' repository is not running and may have been shutdown by the administrator.