10 Replies Latest reply: Mar 9, 2011 3:51 AM by 655560 RSS

    error opening environment

    756043
      Hello,

      I have an application in Java that I deploy in Glassfish 3. The database is Berkeley DB XML.
      The application is used by several clients, so I have one environment for each client.
      When I deploy the application I run this code to each client, to open every environment.
      public class BdbxmlManager {
      
          //+++++++++++++++++++++++++++MAIN VARS++++++++++++++++++++++++++++++++++++++
          public String ENVIRONMENT_PATH = "";
          public static String LOGS_PATH_NAME = "";
          //public String ENVIRONMENT_LOGS_PATH = "";
      
          protected EnvironmentConfig ENVIRONMENT_CONFIG = null;
          protected Environment ENVIRONMENT = null;
          protected static XmlContainerConfig xmlContainerConfig = null;
          
          protected static XmlManagerConfig xmlManagerConfig = null;
          protected static SequenceConfig sequenceConfig = null;
          
          protected static DatabaseConfig sequenceDatabaseConfig = null;
          //protected static TransactionConfig transactionConfig = null;
          protected XmlContainer XML_CONTAINER = null;
          protected XmlContainer XML_CONTAINER_LOGS = null;
          protected XmlContainer XML_CONTAINER_ERROR_LOGS = null;
          protected XmlContainer XML_CONTAINER_MESSAGE = null;
          protected Database SEQUENCE_DATABASE = null;
          protected XmlManager XML_MANAGER = null;
          //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      
          public static String SEQUENCE_DB_NAME = "";
          public static String SEQUENCE_DB_FILE_NAME = "";
          public static String CONTAINER_NAME = "";
          public static String MAIN_DOCUMENT_NAME = "";
          public static String MAIN_DOCUMENT_INITIAL_CONTENT = "";
      
          public static String CONTAINER_MESSAGE = "";
      
          public static String CONTAINER_NAME_LOGS = "";
          public static boolean USING_LOGS_DOCUMENT = false;
          public static String LOGS_DOCUMENT_NAME = "";
          public static String LOGS_DOCUMENT_INITIAL_CONTENT = "";
      
          public static String CONTAINER_NAME_ERROR_LOGS = "";
          public static boolean USING_ERROR_LOGS_DOCUMENT = false;
          public static String ERROR_LOGS_DOCUMENT_NAME = "";
          public static String ERROR_LOGS_DOCUMENT_INITIAL_CONTENT = "";
      
          public static int MAX_LOG_BUFFER_SIZE = 50 * 1024 * 1024;
          public static int MAX_CACHE_SIZE = 5 * 1024 * 1024;
          /**
           * max num of simultaneous active transactions
           */
          public static int MAX_ACTIVE_TXNS = 10000;
          //---------------------DEFAULT ENVIRONMENT CONFIGURATION VALUES---------------------------------
          public static boolean RUN_RECOVERY_BY_DEFAULT = true;
          public static int CACHE_SIZE_BY_DEFAULT = 5 * 1024 * 1024;
          public static int MAX_ACTIVE_TXNS_BY_DEFAULT = 5000;
          public static int LOG_BUFFER_SIZE_BY_DEFAULT = 50 * 1024 * 1024;
          public static boolean ENVIRONMENT_LOG_IN_MEMORY = false;
          public static boolean ENVIRONMENT_LOG_AUTO_REMOVE = true;
          public static int ENVIRONMENT_LOG_REGION_SIZE = 3 * 1024 * 1024;
          public static boolean ENVIRONMENT_TRANSACTIONAL = true;
          public static boolean ENVIRONMENT_THREADED = true;
          public static int ENVIRONMENT_TXN_MAX_ACTIVE = 5000;
          public static int DEFAULT_MAX_LOCKS = 15000;//2000;
          public static int DEFAULT_MAX_LOCKERS = 15000;//2000;
          public static int DEFAULT_MAX_LOCK_OBJECTS = 15000;//2000;
          //---------------------------------------------------------------------------------
          //--------------------SEQUENCE CONFIGURATION VALUES-------------------
          public static boolean ALLOW_CREATE_SEQUENCE_CONFIG = true;
          public static int SEQUENCE_CACHE_SIZE = 0;
          public static boolean DECREMENT_SEQUENCE_CONFIG = false;
          public static int SEQUENCE_MIN_VALUE = 0;
          public static int SEQUENCE_MAX_VALUE = 99999999;
          public static int SEQUENCE_INITIAL_VALUE = 0;
          public static boolean EXCLUSIVE_CREATE_SEQUENCE_CONFIG = false;
          public static boolean WRAP_SEQUENCE_CONFIG = false;
          //----------------------------------------------------------------------ç
          //--------------------XMLMANAGER CONFIGURATION VALUES-------------------
          public static boolean XML_MANAGER_LOG_ENABLED = false;
          public static int XML_MANAGER_LOG_LEVEL = XmlManager.LEVEL_ERROR;
          public static int XML_MANAGER_LOG_CATEGORY = XmlManager.CATEGORY_MANAGER;
          //----------------------------------------------------------------------
          //--------------------XMLCONTAINER CONFIGURATION VALUES-------------------
          public static boolean XML_CONTAINER_INDEX_NODES_AND_STATISTICS_ENABLED = true;
          public static boolean XML_CONTAINER_ALLOW_VALIDATION = false;
          //----------------------------------------------------------------------
          //--------------------SEQUENCE DATABASE CONFIGURATION VALUES-------------------
          public static boolean ALLOW_CREATE_SEQUENCE_DATABASE_CONFIG = true;
          public static boolean TRANSACTIONAL_SEQUENCE_DATABASE_CONFIG = true;
          //----------------------------------------------------------------------
      
      
      
      
          /**
           *  Constructor 
           */
          public BdbxmlManager(String ENVIRONMENT_PATH_NAME) throws DatabaseException, FileNotFoundException, IOException, DbxmlException {
              this.ENVIRONMENT_PATH = ENVIRONMENT_PATH_NAME;
              //this.ENVIRONMENT_LOGS_PATH = ENVIRONMENT_LOGS_PATH_NAME;
      
              init(ENVIRONMENT_PATH);
      
              initXmlManager();
      
              initSequenceDataBase();
      
              //Container message
              File containerMessage = new File(ENVIRONMENT_PATH, CONTAINER_MESSAGE);
              System.out.println("pruebas");
              System.out.println("check container messsage "+containerMessage.getCanonicalPath());
              try{
                  System.out.println("try");
      
                  if (XML_MANAGER.existsContainer(containerMessage.getCanonicalPath()) != 0) {
                      System.out.println("try1");
                      System.out.println("Opening the container message: " + containerMessage + ".....");
                      XML_CONTAINER_MESSAGE = XML_MANAGER.openContainer(containerMessage.getCanonicalPath(), xmlContainerConfig);
                      //System.out.println("Container is transactional: " + XML_CONTAINER.getContainerConfig().getTransactional());
                      XML_CONTAINER_MESSAGE.setAutoIndexing(false);
                      System.out.println("Container message opened!");
      
                  } else {
                      System.out.println("try2");
                      System.out.println("error open container");
                      throw new DbxmlException(DbxmlException.CONTAINER_DOES_NOT_EXIST);
                  }
              }catch(Exception e){
                  System.out.println("EXCEPCION "+e.toString());
              }
      
      
      
      
              //Container data
              File containerFile = new File(ENVIRONMENT_PATH, CONTAINER_NAME);
              System.out.println("check container "+containerFile.getCanonicalPath());
      
              if (XML_MANAGER.existsContainer(containerFile.getCanonicalPath()) != 0) {
                  System.out.println("Opening the container: " + containerFile + ".....");
                  XML_CONTAINER = XML_MANAGER.openContainer(containerFile.getCanonicalPath(), xmlContainerConfig);
                  //System.out.println("Container is transactional: " + XML_CONTAINER.getContainerConfig().getTransactional());
                  XML_CONTAINER.setAutoIndexing(false);
                  System.out.println("Container opened!");
      
                  try {
                      XmlDocument tempDoc = XML_CONTAINER.getDocument(MAIN_DOCUMENT_NAME);
                      //System.out.println("tempDoc no es nulo: " + tempDoc == null);
                  } catch (XmlException e) {
                      if (e.getErrorCode() == XmlException.DOCUMENT_NOT_FOUND) {
                          //System.out.println("El documento " + MAIN_DOCUMENT_NAME + " no existe");
                          //System.out.println("Añadiendo documento....");
                          XML_CONTAINER.putDocument(MAIN_DOCUMENT_NAME, MAIN_DOCUMENT_INITIAL_CONTENT);
                      }
                  }
              } else {
                  throw new DbxmlException(DbxmlException.CONTAINER_DOES_NOT_EXIST);
              }
      
      
              //Container logs
              File containerFileLogs = new File(ENVIRONMENT_PATH, CONTAINER_NAME_LOGS);
              System.out.println("check container "+containerFileLogs.getCanonicalPath());
      
              if (XML_MANAGER.existsContainer(containerFileLogs.getCanonicalPath()) != 0) {
                  System.out.println("Opening the container: " + containerFileLogs + ".....");
                  XML_CONTAINER_LOGS = XML_MANAGER.openContainer(containerFileLogs.getCanonicalPath(), xmlContainerConfig);
                  //System.out.println("Container is transactional: " + XML_CONTAINER.getContainerConfig().getTransactional());
                  XML_CONTAINER_LOGS.setAutoIndexing(false);
                  System.out.println("Container opened!");
      
      
                  //---------------------------LOGS DOCUMENT INITIALIZATION----------------------------------
      
                  try {
                      XML_CONTAINER_LOGS.getDocument(LOGS_DOCUMENT_NAME);
                      //System.out.println("logsDoc no es nulo: " + logsDoc == null);
                  } catch (XmlException e) {
                      if (e.getErrorCode() == XmlException.DOCUMENT_NOT_FOUND) {
                          //System.out.println("El documento " + LOGS_DOCUMENT_NAME + " no existe");
                          //System.out.println("Añadiendo documento....");
                          XML_CONTAINER_LOGS.putDocument(LOGS_DOCUMENT_NAME, LOGS_DOCUMENT_INITIAL_CONTENT);
                      }
                  }
                  
              } else {
                  throw new DbxmlException(DbxmlException.CONTAINER_DOES_NOT_EXIST);
              }
      
      
              //Container error logs
              File containerFileErrorLogs = new File(ENVIRONMENT_PATH, CONTAINER_NAME_ERROR_LOGS);
              System.out.println("check container "+containerFileErrorLogs.getCanonicalPath());
      
              if (XML_MANAGER.existsContainer(containerFileErrorLogs.getCanonicalPath()) != 0) {
                  System.out.println("Opening the container: " + containerFileErrorLogs + ".....");
                  XML_CONTAINER_ERROR_LOGS = XML_MANAGER.openContainer(containerFileErrorLogs.getCanonicalPath(), xmlContainerConfig);
                  //System.out.println("Container is transactional: " + XML_CONTAINER.getContainerConfig().getTransactional());
                  XML_CONTAINER_ERROR_LOGS.setAutoIndexing(false);
                  System.out.println("Container opened!");
      
      
                  //----------------------ERROR LOGS DOCUMENT INITIALIZATION----------------------------------
      
                  try {
                      XML_CONTAINER_ERROR_LOGS.getDocument(ERROR_LOGS_DOCUMENT_NAME);
                      //System.out.println("errorLogsDoc no es nulo: " + errorLogsDoc == null);
                  } catch (XmlException e) {
                      if (e.getErrorCode() == XmlException.DOCUMENT_NOT_FOUND) {
                          //System.out.println("El documento " + ERROR_LOGS_DOCUMENT_NAME + " no existe");
                          //System.out.println("Añadiendo documento....");
                          XML_CONTAINER_ERROR_LOGS.putDocument(ERROR_LOGS_DOCUMENT_NAME, ERROR_LOGS_DOCUMENT_INITIAL_CONTENT);
                      }
                  }
      
              } else {
                  throw new DbxmlException(DbxmlException.CONTAINER_DOES_NOT_EXIST);
              }
      
      
      
      
          }
          /*
           *  Init XmlManager
           */
          protected void initXmlManager() throws XmlException 
          {
              if(XML_MANAGER == null){
                  //---------XmlManager----------------
                  //System.out.println("Creating the XmlManager.....");
                  XML_MANAGER = new XmlManager(ENVIRONMENT, xmlManagerConfig);
                  XmlManager.setLogLevel(XML_MANAGER_LOG_LEVEL, XML_MANAGER_LOG_ENABLED);
                  XmlManager.setLogCategory(XML_MANAGER_LOG_CATEGORY, XML_MANAGER_LOG_ENABLED);
                  //System.out.println("XmlManager created!");
              }
          }
          /*
           *  Init Database
           */
          protected void initSequenceDataBase() throws DatabaseException, FileNotFoundException 
          {
              if(SEQUENCE_DATABASE == null)
              {
                  //---------Sequence Database------------------
                  //System.out.println("Creating/opening the sequence database....");
                  SEQUENCE_DATABASE = ENVIRONMENT.openDatabase(null, SEQUENCE_DB_NAME, SEQUENCE_DB_FILE_NAME, sequenceDatabaseConfig);
                  //System.out.println("Sequence database opened/created!!");
              }
          }
          /*
           *  Configure BdbxmlManager
           */
          protected synchronized void init(String ENVIRONMENT_PATH_NAME) {
              if (ENVIRONMENT_CONFIG == null) {
                  System.out.println("new config en");
                  ENVIRONMENT_CONFIG = initEnvironmentConfiguration();
                  System.out.println("run "+ENVIRONMENT_CONFIG.getRunRecovery());
              }
              if (ENVIRONMENT == null) {
                  System.out.println("nuevo envi");
                  ENVIRONMENT = initEnvironment(ENVIRONMENT_PATH_NAME);
              }
              if (xmlContainerConfig == null) {
                  xmlContainerConfig = initXmlContainerConfiguration();
              }
              if (xmlManagerConfig == null) {
                  xmlManagerConfig = initXmlManagerConfiguration();
              }
              if (sequenceConfig == null) {
                  sequenceConfig = initSequenceConfiguration();
              }
              if (sequenceDatabaseConfig == null) {
                  sequenceDatabaseConfig = initSequenceDatabaseConfig();
              }
          }
      
          /*
           *  INIT ENVIRONMENT CONFIGURATION
           */
          protected static EnvironmentConfig initEnvironmentConfiguration() {
              //System.out.println("Initializing environment configuration....");
              EnvironmentConfig environmentConfig = new EnvironmentConfig();
              environmentConfig.setErrorStream(System.err);
              // If the environment does not exists, create it
              environmentConfig.setAllowCreate(true);
              // Turn on the shared memory region
              environmentConfig.setInitializeCache(true);
              // Turn on the locking subsystem
              environmentConfig.setInitializeRegions(true);
              environmentConfig.setInitializeLocking(true);
              // Turn on the logging subsystem
              environmentConfig.setInitializeLogging(true);
              //environmentConfig.setThreaded(ENVIRONMENT_THREADED);
              environmentConfig.setMaxMutexes(30000);//1000000);//10000);
              environmentConfig.setMutexIncrement(30000);//1000000);//10000);
              environmentConfig.setMaxLockers(DEFAULT_MAX_LOCKERS);
              environmentConfig.setMaxLocks(DEFAULT_MAX_LOCKS);
              environmentConfig.setMaxLockObjects(DEFAULT_MAX_LOCK_OBJECTS);
      
              //----------------------Cache configuration--------------------
              //environmentConfig.setCacheCount(1);
              environmentConfig.setCacheMax(MAX_CACHE_SIZE);
              environmentConfig.setCacheSize(CACHE_SIZE_BY_DEFAULT);
              //------------------------------------------------------------
      
              //----------------------Logging configuration--------------------
              environmentConfig.setLogRegionSize(ENVIRONMENT_LOG_REGION_SIZE);
              environmentConfig.setLogBufferSize(LOG_BUFFER_SIZE_BY_DEFAULT);
              environmentConfig.setLogDirectory(new File(LOGS_PATH_NAME));
              environmentConfig.setLogInMemory(ENVIRONMENT_LOG_IN_MEMORY);
              environmentConfig.setLogAutoRemove(ENVIRONMENT_LOG_AUTO_REMOVE);
              //------------------------------------------------------------
      
              //----------------------Transactions configuration--------------------
              //Turn on the transactional subsystem
              environmentConfig.setTransactional(ENVIRONMENT_TRANSACTIONAL);
              environmentConfig.setTxnMaxActive(ENVIRONMENT_TXN_MAX_ACTIVE);
              //environmentConfig.setTxnNoSync(false);
              //environmentConfig.setTxnNotDurable(false);
              //environmentConfig.setTxnSnapshot(true);
              //environmentConfig.setTxnWriteNoSync(false);
              //----------------------------------------------------------------
      
              //-------------------Run recovery configuration-------------
              environmentConfig.setRunRecovery(RUN_RECOVERY_BY_DEFAULT);
              //----------------------------------------------------------
      
              System.out.println("EnvironmentConfig initialized! run "+environmentConfig.getRunRecovery());
      
      
      
      
              return environmentConfig;
          }
          /*
           *  INIT ENVIRONMENT
           */
      
          protected Environment initEnvironment(String ENVIRONMENT_PATH_NAME) {
      
              Environment env = null;
              //---------Environment--------------
              //System.out.println("Creating the environment....");
              try {
                  System.out.println("start ");
      
                  System.out.println("run recovery "+ENVIRONMENT_CONFIG.getRunRecovery());
                  //ENVIRONMENT_CONFIG.setRunRecovery(true);
                  System.out.println("run recovery "+ENVIRONMENT_CONFIG.getRunRecovery());
      
                  env = new Environment(new File(ENVIRONMENT_PATH_NAME), ENVIRONMENT_CONFIG);
              } catch (DatabaseException ex) {
                  Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
              } catch (FileNotFoundException ex) {
                  Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
              } catch (Exception ex) {
      
                  Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
              }
      
              return env;
          }
      
          /*
           *  CONFIGURE CONTAINER
           */
          protected static XmlContainerConfig initXmlContainerConfiguration() {
      
              //System.out.println("Initializing XmlContainer configuration....");
      
              XmlContainerConfig config = new XmlContainerConfig();
      
              config.setContainerType(XmlContainer.NodeContainer);
              config.setTransactional(ENVIRONMENT_TRANSACTIONAL);
              
              if(XML_CONTAINER_INDEX_NODES_AND_STATISTICS_ENABLED)
              {
                  config.setIndexNodes(XmlContainerConfig.On);
                  config.setStatisticsEnabled(XmlContainerConfig.On);
              }else
              {
                  config.setIndexNodes(XmlContainerConfig.Off);
                  config.setStatisticsEnabled(XmlContainerConfig.Off);
              }        
              config.setAllowValidation(XML_CONTAINER_ALLOW_VALIDATION);
              //System.out.println("XmlContainer configuration initialized!");
              return config;
          }
      
          /*
           *  INIT XML MANAGER CONFIGURATION
           */
          protected static XmlManagerConfig initXmlManagerConfiguration() {
              //System.out.println("Initializing XmlManager configuration....");
              XmlManagerConfig config = new XmlManagerConfig();
              config.setAdoptEnvironment(false);
              config.setAllowAutoOpen(true);
              config.setAllowExternalAccess(true);
              //System.out.println("XmlManager configuration initialized!");
              return config;
          }
      
          /*
           *  INIT SEQUENCE CONFIGURATION
           */
          protected SequenceConfig initSequenceConfiguration() {
      
              //System.out.println("Initializing Sequence configuration....");
              SequenceConfig config = new SequenceConfig();
              config.setAllowCreate(ALLOW_CREATE_SEQUENCE_CONFIG);
              config.setCacheSize(SEQUENCE_CACHE_SIZE);
              config.setDecrement(DECREMENT_SEQUENCE_CONFIG);
              config.setRange(SEQUENCE_MIN_VALUE, SEQUENCE_MAX_VALUE);
              config.setInitialValue(SEQUENCE_INITIAL_VALUE);
              config.setExclusiveCreate(EXCLUSIVE_CREATE_SEQUENCE_CONFIG);
              config.setWrap(WRAP_SEQUENCE_CONFIG);
              //System.out.println("Sequence configuration initialized!");
              return config;
          }
      
          /*
           *  INIT SEQUENCE DATABASE CONFIG
           */
          protected DatabaseConfig initSequenceDatabaseConfig() {
              DatabaseConfig config = new DatabaseConfig();
              config.setAllowCreate(ALLOW_CREATE_SEQUENCE_DATABASE_CONFIG);
              config.setTransactional(TRANSACTIONAL_SEQUENCE_DATABASE_CONFIG);
              config.setType(DatabaseType.BTREE);
              return config;
          }
      
          /**
           * Creates a new Xml transaction
           * @return
           * @throws XmlException
           */
          public XmlTransaction createTransaction() throws XmlException {
              XmlTransaction xmlTransaction = XML_MANAGER.createTransaction();
              return xmlTransaction;
          }
      
          /**
      
           */
          public XmlResults executeQuery(XmlTransaction transaction, DbxmlQuery query,
                  boolean commitTransaction) throws XmlException, DbxmlException {
      
              XmlQueryExpression queryExpression = query.getXmlQueryExpression();
      
              if (queryExpression.isUpdateExpression()) {
                  throw new DbxmlException(DbxmlException.UPDATE_ATTEMPTED_IN_READ_QUERY);
              } else {
                  XmlResults results = null;
      
                  try {
                      if (transaction != null) {
                          results = queryExpression.execute(transaction, query.getXmlQueryContext());
                          if (commitTransaction) {
                              transaction.commit();
                          }
                      } else {
                          results = queryExpression.execute(query.getXmlQueryContext());
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
      
                      //Aborting the transaction since there was an exception and it
                      //could not be committed
                      if (transaction != null) {
                          //System.out.println("Aborting the transaction due to underlying exception... ");
                          transaction.abort();
                          //System.out.println("Transaction aborted :(");
                      }
                      if (results != null) {
                          //System.out.println("Deleting the XmlResults due to aborting the transaction...");
                          results.delete();
                          //System.out.println("XmlResults deleted :(");
                      }
                      if (queryExpression != null) {
                          //System.out.println("Deleting the QueryExpression due to aborting the transaction...");
                          queryExpression.delete();
                          //System.out.println("Query expression deleted :(");
                      }
                  }
                  return results;
              }
          }
      
          /**
           */
          public XmlResults executeUpdateQuery(XmlTransaction transaction, DbxmlQuery query,
                  boolean commitTransaction) throws XmlException, DbxmlException {
      
      
              XmlQueryExpression queryExpression = query.getXmlQueryExpression();
      
              if (!queryExpression.isUpdateExpression()) {
                  throw new DbxmlException(DbxmlException.UPDATE_QUERY_EXPECTED);
              } else {
                  XmlResults results = null;
                  try {
                      BasicMonitor.getMonitor().getLock();
                      if (transaction != null) {
                          results = queryExpression.execute(transaction, query.getXmlQueryContext());
                          if (commitTransaction) {
                              transaction.commit();
                          }
                      } else {
                          results = queryExpression.execute(query.getXmlQueryContext());
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
      
                      //Aborting the transaction since there was an exception and it
                      //could not be committed
                      if (transaction != null) {
                          //System.out.println("Aborting the transaction due to underlying exception... ");
                          transaction.abort();
                          //System.out.println("Transaction aborted :(");
                      }
                      if (results != null) {
                          //System.out.println("Deleting the XmlResults due to aborting the transaction...");
                          results.delete();
                          //System.out.println("XmlResults deleted :(");
                      }
                      if (queryExpression != null) {
                          //System.out.println("Deleting the QueryExpression due to aborting the transaction...");
                          queryExpression.delete();
                          //System.out.println("Query expression deleted :(");
                      }
                  } finally {
                      BasicMonitor.getMonitor().releaseLock();
                  }
      
                  return results;
              }
          }
      
          /**
           * Closes all resources associated to this manager
           */
          public synchronized void close() {
              //xmlContainer.close();
              if(XML_MANAGER != null)
              {   try {
                      closeSequenceDataBase();
                      closeXmlContainer();
                      //System.out.println("Closing XML_MANAGER...");
                      XML_MANAGER.close();
                      //System.out.println("XML_MANAGER closed! :)");
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          }
          /**
           * Get the XmlManager
           */
          public XmlManager getXmlManager() {
              return XML_MANAGER;
          }
          /**
           * Get the Database
           */
          public Database getDatabase() {
              return SEQUENCE_DATABASE;
          }
          /**
           * Return the SequenceConfig
           */
          public SequenceConfig getSequenceConfig() {
              return sequenceConfig;
          }
          /**
           * Close the DataBase
           */
          private synchronized void closeSequenceDataBase() {
              if (SEQUENCE_DATABASE != null) {
                  try {
                      //System.out.println("Closing the sequence database...");
                      SEQUENCE_DATABASE.close(false);
                      //System.out.println("Sequence database closed! :)");
                  } catch (DatabaseException ex) {
                      //System.out.println("There was a problem closing the sequence database... :(");
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
          }
          /**
           * Close the XmlContainer
           */
          private synchronized void closeXmlContainer() {
              if (XML_CONTAINER != null) {
                  try {
                      System.out.println("Closing the XmlContainer....");
                      XML_CONTAINER.close();
                      //System.out.println("XmlContainer closed! :)");
                  } catch (Exception ex) {
                      //System.out.println("There was a problem closing the XmlContainer... :(");
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
              if (XML_CONTAINER_LOGS != null) {
                  try {
                      System.out.println("Closing the XmlContainer....");
                      XML_CONTAINER_LOGS.close();
                      //System.out.println("XmlContainer closed! :)");
                  } catch (Exception ex) {
                      //System.out.println("There was a problem closing the XmlContainer... :(");
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
              if (XML_CONTAINER_ERROR_LOGS != null) {
                  try {
                      System.out.println("Closing the XmlContainer....");
                      XML_CONTAINER_ERROR_LOGS.close();
                      //System.out.println("XmlContainer closed! :)");
                  } catch (Exception ex) {
                      //System.out.println("There was a problem closing the XmlContainer... :(");
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
      
              if (XML_CONTAINER_MESSAGE != null) {
                  try {
                      System.out.println("Closing the message XmlContainer....");
                      XML_CONTAINER_MESSAGE.close();
                      //System.out.println("XmlContainer closed! :)");
                  } catch (Exception ex) {
                      //System.out.println("There was a problem closing the XmlContainer... :(");
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
      
          }
          /**
           * Close the Environment
           */
          public synchronized void closeEnvironment() {
              if (ENVIRONMENT != null) {
                  try {
                      System.out.println("Closing the environment....");
                      System.out.println("Closing the environment....");
                      ENVIRONMENT.close();
                      System.out.println("Environment closed! :)");
      
                      //singleton = null;
                      
                  } catch (IllegalArgumentException ex) {
                      System.out.println("There was IllegalArgumentException");
      
                      System.out.println("There was a problem closing the environment... :( "+ex.toString());
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
                      
                  } catch (DatabaseException ex) {
                      //System.out.println("There was a problem closing the environment... :(");
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
      
                  } catch (Exception ex) {
      
                      System.out.println("There was general problem "+ex.toString());
                      Logger.getLogger(BdbxmlManager.class.getName()).log(Level.SEVERE, null, ex);
                  }
              }
          }
      
      }
        • 1. Re: error opening environment
          756043
          I continue the message before....



          After using the application for many days, the application failed and it hangs. The glassfish went down.
          So when I deploy the appllication again it stops in the line and I get no exception or error.
          if (XML_MANAGER.existsContainer(containerMessage.getCanonicalPath()) != 0) {
          Then I started to debug the code and I realize that when I open the environment in this line:
          env = new Environment(new File(ENVIRONMENT_PATH_NAME), ENVIRONMENT_CONFIG);
          then configuration of ENVIRONMENT_CONFIG.getRunRecovery() was set to false.

          So then I changed the settings and I set ENVIRONMENT_CONFIG.setRunRecovery(true).


          After that I deployed the application again and I got this errors:



          +[#|2011-03-04T15:05:27.900+0000|SEVERE|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|Log+
          sequence error: page LSN 12 3990397; previous LSN 13 675423
          +|#]+

          +[#|2011-03-04T15:05:27.900+0000|SEVERE|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|Recovery+
          function for LSN 13 705277 failed on forward pass
          +|#]+

          +[#|2011-03-04T15:05:27.901+0000|SEVERE|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|PANIC:+
          Invalid argument
          +|#]+

          +[#|2011-03-04T15:05:28.203+0000|SEVERE|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Thread-1;|unable+
          to join the environment
          +|#]+

          +[#|2011-03-04T15:05:28.258+0000|SEVERE|glassfishv3.0|com.era7.lib.bdbxmlapi.BdbxmlManager|_ThreadID=11;_ThreadName=Thread-1;|The+
          log message is null.
          com.sleepycat.db.RunRecoveryException: DB_RUNRECOVERY: Fatal error,
          run database recovery: PANIC: Invalid argument
          unable to join the environment: DB_RUNRECOVERY: Fatal error, run
          database recovery
          at com.sleepycat.db.internal.db_javaJNI.DbEnv_open(Native Method)
          at com.sleepycat.db.internal.DbEnv.open(DbEnv.java:317)
          at com.sleepycat.db.EnvironmentConfig.openEnvironment(EnvironmentConfig.java:3886)
          at com.sleepycat.db.Environment.<init>(Environment.java:93)
          at com.era7.lib.bdbxmlapi.BdbxmlManager.initEnvironment(BdbxmlManager.java:384)
          at com.era7.lib.bdbxmlapi.BdbxmlManager.init(BdbxmlManager.java:294)
          at com.era7.lib.bdbxmlapi.BdbxmlManager.<init>(BdbxmlManager.java:135)
          at com.era7.doPlanning.appConf.listeners.DoPlanningApplicationListener.createManager(DoPlanningApplicationListener.java:177)
          at com.era7.doPlanning.appConf.listeners.DoPlanningApplicationListener.configureBdbxmlInitializationParams(DoPlanningApplicationListener.java:105)
          at com.era7.lib.slbdbxml.listeners.AbstractApplicationListener.contextInitialized(AbstractApplicationListener.java:51)
          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4591)
          at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:535)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5193)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1933)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1605)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
          at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
          at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
          at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:340)
          at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:163)
          at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
          at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
          at java.security.AccessController.doPrivileged(Native Method)
          at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
          at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
          at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
          at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
          at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
          at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
          at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
          at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
          at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
          at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
          at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
          at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
          at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
          at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
          at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
          at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
          at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
          at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
          at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
          at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
          at java.lang.Thread.run(Thread.java:619)
          +|#]+

          +[#|2011-03-04T15:05:28.272+0000|SEVERE|glassfishv3.0|com.era7.doPlanning.appConf.listeners.DoPlanningApplicationListener|_ThreadID=11;_ThreadName=Thread-1;|The+
          log message is null.
          com.sleepycat.dbxml.XmlException: Invalid Environment object, may be
          closed., errcode = DATABASE_ERROR
          at com.sleepycat.db.XmlHelper.getDbEnv(XmlHelper.java:29)
          at com.sleepycat.dbxml.XmlManager.<init>(XmlManager.java:55)
          at com.era7.lib.bdbxmlapi.BdbxmlManager.initXmlManager(BdbxmlManager.java:265)
          at com.era7.lib.bdbxmlapi.BdbxmlManager.<init>(BdbxmlManager.java:137)
          at com.era7.doPlanning.appConf.listeners.DoPlanningApplicationListener.createManager(DoPlanningApplicationListener.java:177)
          at com.era7.doPlanning.appConf.listeners.DoPlanningApplicationListener.configureBdbxmlInitializationParams(DoPlanningApplicationListener.java:105)
          at com.era7.lib.slbdbxml.listeners.AbstractApplicationListener.contextInitialized(AbstractApplicationListener.java:51)
          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4591)
          at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:535)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:5193)
          at com.sun.enterprise.web.WebModule.start(WebModule.java:499)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:928)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:912)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:694)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1933)
          at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1605)
          at com.sun.enterprise.web.WebApplication.start(WebApplication.java:90)
          at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
          at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241)
          at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236)
          at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339)
          at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:340)
          at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:163)
          at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:174)
          at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:87)
          at java.security.AccessController.doPrivileged(Native Method)
          at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:84)
          at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:77)
          at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
          at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
          at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
          at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:236)
          at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:128)
          at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:457)
          at com.sun.enterprise.module.bootstrap.Main.launch(Main.java:401)
          at org.jvnet.hk2.osgiadapter.HK2Main.start(HK2Main.java:125)
          at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
          at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
          at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
          at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:915)
          at org.jvnet.hk2.osgimain.Main.start(Main.java:140)
          at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:640)
          at org.apache.felix.framework.Felix.activateBundle(Felix.java:1700)
          at org.apache.felix.framework.Felix.startBundle(Felix.java:1622)
          at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1077)
          at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:264)
          at java.lang.Thread.run(Thread.java:619)
          +|#]+




          For more information, when I run db_recover I got this errors


          BXML.2.5/bin/db_recover -c

          db_recover: Log sequence error: page LSN 12 3990397; previous LSN 13 675423
          db_recover: Recovery function for LSN 13 705277 failed on forward pass
          db_recover: PANIC: Invalid argument
          db_recover: PANIC: fatal region error detected; run recovery
          db_recover: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanning.dbxml:
          write failed for page 764
          db_recover: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanning.dbxml:
          unable to flush page: 764
          db_recover: process-private: unable to find environment
          db_recover: DB_ENV->open: DB_RUNRECOVERY: Fatal error, run database recovery



          BXML.2.5/bin/db_recover -c -v

          Finding last valid log LSN: file: 34 offset 10311907
          Recovery starting from [1][28]
          db_recover: Log sequence error: page LSN 12 3990397; previous LSN 13 675423
          db_recover: Recovery function for LSN 13 705277 failed on forward pass
          db_recover: PANIC: Invalid argument
          db_recover: PANIC: fatal region error detected; run recovery
          db_recover: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanning.dbxml:
          write failed for page 764
          db_recover: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanning.dbxml:
          unable to flush page: 764
          db_recover: process-private: unable to find environment
          db_recover: DB_ENV->open: DB_RUNRECOVERY: Fatal error, run database recovery




          When I run db_stat -e:

          Mon Mar  7 09:22:23 2011        Local time
          +0x120897 Magic number+
          +0 Panic value+
          +4.8.24 Environment version+
          +9 Btree version+
          +9 Hash version+
          +1 Lock version+
          +15 Log version+
          +4 Queue version+
          +2 Sequence version+
          +1 Txn version+
          Fri Mar  4 15:34:36 2011        Creation time
          +0xcf201e5f Environment ID+
          +2 Primary region allocation and reference count mutex [0/4 0% !Own]+
          +3 References+
          +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
          +0x40988 Log magic number+
          +15 Log version number+
          +50MB Log record cache size+
          +0 Log file mode+
          +10Mb Current log file size+
          +9777 Records entered into the log+
          +895KB 899B Log bytes written+
          +895KB 899B Log bytes written since last checkpoint+
          +123 Total log file I/O writes+
          +0 Total log file I/O writes due to overflow+
          +123 Total log file flushes+
          +24737 Total log file I/O reads+
          +34 Current log file number+
          +10435138 Current log file offset+
          +34 On-disk log file number+
          +10435138 On-disk log file offset+
          +1 Maximum commits in a log flush+
          +1 Minimum commits in a log flush+
          +50MB 256KB Log region size+
          +0 The number of region locks that required waiting (0%)+
          +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
          +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
          +2123 Last allocated locker ID+
          +0x7fffffff Current maximum unused locker ID+
          +9 Number of lock modes+
          +15000 Maximum number of locks possible+
          +15000 Maximum number of lockers possible+
          +15000 Maximum number of lock objects possible+
          +1 Number of lock object partitions+
          +176 Number of current locks+
          +182 Maximum number of locks at any one time+
          +20 Maximum number of locks in any one bucket+
          +0 Maximum number of locks stolen by for an empty partition+
          +0 Maximum number of locks stolen for any one partition+
          +346 Number of current lockers+
          +361 Maximum number of lockers at any one time+
          +44 Number of current lock objects+
          +70 Maximum number of lock objects at any one time+
          +2 Maximum number of lock objects in any one bucket+
          +0 Maximum number of objects stolen by for an empty partition+
          +0 Maximum number of objects stolen for any one partition+
          +158M Total number of locks requested (158999583)+
          +158M Total number of locks released (158999340)+
          +0 Total number of locks upgraded+
          +727 Total number of locks downgraded+
          +19 Lock requests not available due to conflicts, for which we waited+
          +11 Lock requests not available due to conflicts, for which we did not wait+
          +0 Number of deadlocks+
          +0 Lock timeout value+
          +0 Number of locks that have timed out+
          +0 Transaction timeout value+
          +0 Number of transactions that have timed out+
          +7MB 840KB The size of the lock region+
          +0 The number of partition locks that required waiting (0%)+
          +0 The maximum number of times any partition lock was waited for (0%)+
          +0 The number of object queue operations that required waiting (0%)+
          +0 The number of locker allocations that required waiting (0%)+
          +115 The number of region locks that required waiting (0%)+
          +2 Maximum hash bucket length+
          +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
          +6MB 257KB 604B Total cache size+
          +1 Number of caches+
          +1 Maximum number of caches+
          +6MB 264KB Pool individual cache size+
          +0 Maximum memory-mapped file size+
          +0 Maximum open file descriptors+
          +0 Maximum sequential buffer writes+
          +0 Sleep after writing maximum sequential buffers+
          +10 Requested pages mapped into the process' address space+
          +344M Requested pages found in the cache (99%)+
          +1282817 Requested pages not found in the cache+
          +3319 Pages created in the cache+
          +1282817 Pages read into the cache+
          +7780 Pages written from the cache to the backing file+
          +1277963 Clean pages forced from the cache+
          +7779 Dirty pages forced from the cache+
          +0 Dirty pages written by trickle-sync thread+
          +395 Current total page count+
          +389 Current clean page count+
          +6 Current dirty page count+
          +1031 Number of hash buckets used for page location+
          +4096 Assumed page size used+
          +346M Total number of times hash chains searched for a page (346931510)+
          +4 The longest hash chain searched for a page+
          +389M Total number of hash chain entries checked for page (389374869)+
          +0 The number of hash bucket locks that required waiting (0%)+
          +0 The maximum number of times any hash bucket lock was waited for (0%)+
          +0 The number of region locks that required waiting (0%)+
          +0 The number of buffers frozen+
          +0 The number of buffers thawed+
          +0 The number of frozen buffers freed+
          +1286173 The number of page allocations+
          +5923486 The number of hash buckets examined during allocations+
          +29 The maximum number of hash buckets examined for an allocation+
          +1285743 The number of pages examined during allocations+
          +2 The max number of pages examined for an allocation+
          +0 Threads waited on page I/O+
          +0 The number of times a sync is interrupted+
          Pool File: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanningLogs.dbxml
          +16384 Page size+
          +0 Requested pages mapped into the process' address space+
          +766861 Requested pages found in the cache (99%)+
          +3408 Requested pages not found in the cache+
          +9 Pages created in the cache+
          +3408 Pages read into the cache+
          +595 Pages written from the cache to the backing file+
          Pool File: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanning.dbxml
          +16384 Page size+
          +0 Requested pages mapped into the process' address space+
          +344M Requested pages found in the cache (99%)+
          +1278423 Requested pages not found in the cache+
          +3309 Pages created in the cache+
          +1278423 Pages read into the cache+
          +7117 Pages written from the cache to the backing file+
          Pool File: sequenceDb
          +16384 Page size+
          +0 Requested pages mapped into the process' address space+
          +2 Requested pages found in the cache (25%)+
          +6 Requested pages not found in the cache+
          +0 Pages created in the cache+
          +6 Pages read into the cache+
          +1 Pages written from the cache to the backing file+
          Pool File: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanningMessages.dbxml
          +16384 Page size+
          +0 Requested pages mapped into the process' address space+
          +7111 Requested pages found in the cache (88%)+
          +926 Requested pages not found in the cache+
          +1 Pages created in the cache+
          +926 Pages read into the cache+
          +58 Pages written from the cache to the backing file+
          Pool File: /DBPool/DoPlanning/DoPlanningDB/era7/doPlanningErrorLogs.dbxml
          +16384 Page size+
          +0 Requested pages mapped into the process' address space+
          +1322 Requested pages found in the cache (96%)+
          +54 Requested pages not found in the cache+
          +0 Pages created in the cache+
          +54 Pages read into the cache+
          +9 Pages written from the cache to the backing file+
          +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
          +0/0 No checkpoint LSN+
          Fri Mar  4 15:34:47 2011        Checkpoint timestamp
          +0x80000b22 Last transaction ID allocated+
          +5000 Maximum number of active transactions configured+
          +18 Active transactions+
          +22 Maximum active transactions+
          +2850 Number of transactions begun+
          +12 Number of transactions aborted+
          +2820 Number of transactions committed+
          +0 Snapshot transactions+
          +0 Maximum snapshot transactions+
          +0 Number of transactions restored+
          +1MB 456KB Transaction region size+
          +0 The number of region locks that required waiting (0%)+
          Active transactions:
          +800009c2: running; pid/thread 29365/1322; begin LSN: file/offset 0/0+
          +800009d2: running; pid/thread 29365/1323; begin LSN: file/offset 0/0+
          +800009e0: running; pid/thread 29365/1332; begin LSN: file/offset 0/0+
          +800009ec: running; pid/thread 29365/1333; begin LSN: file/offset 0/0+
          +800009f8: running; pid/thread 29365/1334; begin LSN: file/offset 0/0+
          +80000a04: running; pid/thread 29365/1335; begin LSN: file/offset 0/0+
          +80000a10: running; pid/thread 29365/1336; begin LSN: file/offset 0/0+
          +80000a17: running; pid/thread 29365/1337; begin LSN: file/offset 0/0+
          +80000a23: running; pid/thread 29365/1338; begin LSN: file/offset 0/0+
          +80000a35: running; pid/thread 29365/1339; begin LSN: file/offset 0/0+
          +80000a58: running; pid/thread 29365/1341; begin LSN: file/offset 0/0+
          +80000a62: running; pid/thread 29365/1349; begin LSN: file/offset 0/0+
          +80000a74: running; pid/thread 29365/1350; begin LSN: file/offset 0/0+
          +80000a80: running; pid/thread 29365/1351; begin LSN: file/offset 0/0+
          +80000a8c: running; pid/thread 29365/1352; begin LSN: file/offset 0/0+
          +80000a98: running; pid/thread 29365/1353; begin LSN: file/offset 0/0+
          +80000aa6: running; pid/thread 29365/1354; begin LSN: file/offset 0/0+
          +80000ad1: running; pid/thread 29365/134; begin LSN: file/offset 0/0+
          +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
          +3MB 448KB Mutex region size+
          +0 The number of region locks that required waiting (0%)+
          +4 Mutex alignment+
          +1 Mutex test-and-set spins+
          +30000 Mutex total count+
          +28206 Mutex free count+
          +1794 Mutex in-use count+
          +1819 Mutex maximum in-use count+
          Mutex counts
          +28206 Unallocated+
          +116 db handle+
          +2 env dblist+
          +4 env handle+
          +1 env region+
          +4 lock region+
          +182 logical lock+
          +1 log filename+
          +1 log flush+
          +3 log region+
          +5 mpoolfile handle+
          +395 mpool buffer+
          +10 mpool filehandle+
          +17 mpool file bucket+
          +2 mpool handle+
          +1031 mpool hash bucket+
          +1 mpool region+
          +1 mutex region+
          +12 sequence+
          +2 twister+
          +2 txn active list+
          +1 transaction checkpoint+
          +1 txn region+



          I try to run db_verify but I don't know the right way and I get:

          +db_verify [-NoqV] [-h home] [-P password] db_file ...+


          Thank you for everything
          • 2. Re: error opening environment
            655560
            Hi,

            Please backup your data and try to reset the LSN to see if it can solve the problem:
            db_load -r lsn <path_to_container>
            Best regards,
            Rucong Zhao
            Oracle Berkeley DB XML
            • 3. Re: error opening environment
              756043
              Hi,

              How can I backup my data? You mean, make a copy of the files in another folder?
              Sorry, but I'm not very familiar with backups

              Thank you so much
              • 4. Re: error opening environment
                655560
                Hi,

                To prevent potential operations destroy the data, just copy all files to another folder (including log.*, __db* and database file). It's just a general backup method.

                You also can use dbxml_dump/dbxml_load to backup and restore data.

                Best regards,
                Rucong Zhao
                Oracle Berkeley DB XML
                • 5. Re: error opening environment
                  756043
                  I have got 4 containers in the environment. So after copying the files I ran:

                  db_load -r lsn container1.dbxml

                  db_load -r lsn container2.dbxml

                  db_load -r lsn container3.dbxml

                  db_load -r lsn container4.dbxml


                  But the problem persists when I deploy the application

                  Thanks
                  • 6. Re: error opening environment
                    655560
                    Hi,

                    Since you've backup all files, try performing catastrophic recovery instead of normal recovery: Do check point once (db_checkpoint -1), removing all log files and run "db_recovery -c".

                    Best regards,
                    Rucong Zhao
                    Oracle Berkeley DB XML
                    • 7. Re: error opening environment
                      756043
                      I try to do db_checkpoint -1 but I get the error:
                      unable to join the environment.

                      These are all the files I've got in the directory:

                      -rw-r--r-- 1 root root 24576 2011-03-08 19:15 __db.001
                      -rw-r--r-- 1 root root 3604480 2011-03-08 19:15 __db.002
                      -rw-r--r-- 1 root root 6561792 2011-03-08 19:15 __db.003
                      -rw-r--r-- 1 root root 52690944 2011-03-08 19:15 __db.004
                      -rw-r--r-- 1 root root 8200192 2011-03-08 19:15 __db.005
                      -rw-r--r-- 1 root root 1515520 2011-03-08 19:15 __db.006
                      -rw-r----- 1 root root 38453248 2011-03-08 19:08 dP.dbxml
                      -rw-r----- 1 root root 360448 2011-03-08 16:53 dPErrorLogs.dbxml
                      -rw-r----- 1 root root 1835008 2011-03-08 19:08 dPLogs.dbxml
                      -rw-r----- 1 root root 36569088 2011-03-08 18:52 dPMessages.dbxml
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000001
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000002
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000003
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000004
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000005
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000006
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000007
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000008
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:32 log.0000000009
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:36 log.0000000010
                      -rw-r--r-- 1 root root 10485760 2011-02-19 14:36 log.0000000011
                      -rw-r--r-- 1 root root 10485760 2011-03-03 13:01 log.0000000012
                      -rw-r--r-- 1 root root 10485760 2011-03-09 08:18 log.0000000013
                      -rw-r--r-- 1 root root 65536 2011-03-08 15:08 sequenceDb
                      • 8. Re: error opening environment
                        655560
                        Hi,

                        It seems that the log is crushed. Is dbxml_dump / dbxml_load works? e.g.:
                        ./dbxml_dump -h . dPMessages.dbxml -f dpMessages.dump
                        (copy dpMessages.dump to a new directory)
                        ./dbxml_load -h . dPMessages.dbxml -f dpMessages.dump
                        Best regards,
                        Rucong Zhao
                        Oracle Berkeley DB XML
                        • 9. Re: error opening environment
                          756043
                          I tried db_dump as you said and I get:

                          usage: dbxml_dump [-rRV]
                          [-f output] [-h home] [-P password] xml_container


                          Thanks again
                          • 10. Re: error opening environment
                            655560
                            Hi,

                            It seems that your platorm is argument sequence sensitive. Please try "./dbxml_dump -h . -f test.dump test.dbxml".

                            If there are any future questions, please send an email to me (rucong.zhao@oracle.com). Thanks.

                            Best regards,
                            Rucong Zhao
                            Oracle Berkeley DB XML