5 Replies Latest reply on Dec 3, 2012 3:49 AM by Horia Chiorean

    repository cannot be started because transactions are not enabled

    Jason Hall Newbie

      I get this error

       

      javax.jcr.RepositoryException: Error while starting 'my_repository' repository: The 'my_repository' repository cannot be started because transactions are not enabled. Please check your configuration.

      Shutting down engine ...

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:611)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:578)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:147)

                at com.jlencore.service.jcr.example.modeshape.ModeShapeTester.main(ModeShapeTester.java:63)

      Caused by: java.lang.IllegalStateException: The 'my_repository' repository cannot be started because transactions are not enabled. Please check your configuration.

                at org.modeshape.jcr.JcrRepository$RunningState.validateTransactionsEnabled(JcrRepository.java:1217)

                at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:1046)

                at org.modeshape.jcr.JcrRepository$RunningState.<init>(JcrRepository.java:960)

                at org.modeshape.jcr.JcrRepository.doStart(JcrRepository.java:352)

                at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:609)

                ... 3 more

       

       

      My infinispan-configuration.xml

      {

          "name" : "my_repository",

          "jndiName" :"",

          "transactionMode" : "auto",

          "monitoring" : {

              "enabled" : true,

          },

          "workspaces" : {

              "predefined" : ["otherWorkspace"],

              "default" : "default",

              "allowCreation" : true,

          },

          "storage" : {

              "cacheName" : "my_repository",

              "cacheConfiguration" : "infinispan-configuration.xml",

              "transactionManagerLookup" = "org.infinispan.transaction.lookup.GenericTransactionManagerLookup",

              "binaryStorage" : {

                  "type" : "file",

                  "directory" : "my_repository/binaries",

                  "minimumBinarySizeInBytes" : 4096

              }

          }

       

       

      }

       

       

      Java Code

       

      public static void main(String[] args) {

                          // TODO Auto-generated method stub

                          //ModeShapeEngine engine = new ModeShapeEngine();

                          //engine.start();

                          // Create and start the engine ...

              ModeShapeEngine engine = new ModeShapeEngine();

              engine.start();

       

       

              // Load the configuration for a repository via the classloader (can also use path to a file)...

              Repository repository = null;

              String repositoryName = null;

              try {

                  URL url = ModeShapeTester.class.getClassLoader().getResource("my_repository.json");

                  RepositoryConfiguration config = RepositoryConfiguration.read(url);

       

       

                  // We could change the name of the repository programmatically ...

                  // config = config.withName("Some Other Repository");

       

       

                  // Verify the configuration for the repository ...

                  Problems problems = config.validate();

                  if (problems.hasErrors()) {

                      System.err.println("Problems starting the engine.");

                      System.err.println(problems);

                      System.exit(-1);

                  }

       

       

                  // Deploy the repository ...

                  repository = engine.deploy(config);

                  repositoryName = config.getName();

              } catch (Throwable e) {

                  e.printStackTrace();

                  System.exit(-1);

                  return;

              }

       

       

              Session session = null;

              try {

                  // Get the repository

                  repository = engine.getRepository(repositoryName);

       

       

                  // Create a session ...

                  session = repository.login("default");

       

       

                  // Get the root node ...

                  Node root = session.getRootNode();

                  assert root != null;

                  useWorkspace(root);

                  session.save();

                  System.out.println("Found the root node in the \"" + session.getWorkspace().getName() + "\" workspace");

              } catch (RepositoryException e) {

                  e.printStackTrace();

              } finally {

                  if (session != null) session.logout();

                  System.out.println("Shutting down engine ...");

                  try {

                      engine.shutdown().get();

                      System.out.println("Success!");

                  } catch (Exception e) {

                      e.printStackTrace();

                  }

              }

       

       

                }

        • 1. Re: repository cannot be started because transactions are not enabled
          Horia Chiorean Master

          Hi Jason,

           

          Can you please post your infinispan-configuration.xml file ?

           

          This exception is thrown when Inifinispan isn't configured to use transactions, because ModeShape does require a transactional configuration. Since you've configured an explicit Infinispan xml file, that will have precendece as far as cache configuration goes.

          • 2. Re: repository cannot be started because transactions are not enabled
            Jason Hall Newbie

            sorry.  infinispa-configuration.xml just has the empty tag below:

             

            <infinispan />

            • 3. Re: repository cannot be started because transactions are not enabled
              Horia Chiorean Master

              In the case when you're defining an Infinispan xml config file, you need that file to contain a valid transactional cache configuration (e.g. https://github.com/ModeShape/modeshape/blob/master/modeshape-jcr/src/test/resources/config/infinispan-persistent.xml)

               

              The other option, is to not use a "cacheConfiguration"  element in the ModeShape JSON config file, case in which the other JSON attributes (e.g. transactionManagerLookup) should work as configured.

              • 4. Re: repository cannot be started because transactions are not enabled
                Jason Hall Newbie

                I removed the call to infinispan-confugration.xml from the json config file and the error went away.  But is it persisted because I run a sample program to add a node and uncomment that code and perform a get on that node and

                I get this error.

                 

                Creating node ...

                javax.jcr.PathNotFoundException: The child "SampleNode" could not be found under "/" in workspace "default"

                          at org.modeshape.jcr.AbstractJcrNode.getNode(AbstractJcrNode.java:784)

                          at org.modeshape.jcr.AbstractJcrNode.getNode(AbstractJcrNode.java:107)

                          at com.jlencore.service.jcr.example.modeshape.ModeShapeTester.useWorkspace(ModeShapeTester.java:89)

                          at com.jlencore.service.jcr.example.modeshape.ModeShapeTester.main(ModeShapeTester.java:68)

                Shutting down engine ...

                 

                 

                SEE BELOW FOR THE CODE GETTING THE NODE. IT'S COMMENTED OUT BECAUSE IT'S EXECUTED A SECOND TIME THINKING THAT THE NODE WAS PERSISTED ON THE 1ST EXECUTION.

                 

                 

                        Session session = null;

                        try {

                            // Get the repository

                            repository = engine.getRepository(repositoryName);

                 

                 

                            // Create a session ...

                            session = repository.login("default");

                 

                 

                            // Get the root node ...

                            Node root = session.getRootNode();

                            assert root != null;

                            useWorkspace(root);

                            session.save();

                            System.out.println("Found the root node in the \"" + session.getWorkspace().getName() + "\" workspace");

                        } catch (RepositoryException e) {

                            e.printStackTrace();

                        } finally {

                            if (session != null) session.logout();

                            System.out.println("Shutting down engine ...");

                            try {

                                engine.shutdown().get();

                                System.out.println("Success!");

                            } catch (Exception e) {

                                e.printStackTrace();

                            }

                        }

                 

                 

                          }

                 

                          public static void useWorkspace(Node node) throws RepositoryException{

                                    System.out.println("Creating node ...");

                                    //node.addNode("SampleNode");

                                    Node n = node.getNode("SampleNode");

                                    System.out.println(" node output = "+n);

                 

                          }

                • 5. Re: repository cannot be started because transactions are not enabled
                  Horia Chiorean Master

                  Running the above JSON configuration without any Infinispan XML, will produce an in-memory repository, meaning that the data isn't persisted across restarts. Therefore, in this case you need to add "SampleNode" below root each time.

                   

                  If you want the data to be persistent, you need an Infinispan XML file with the appropriate cache-loader configured. The one from the previous link, for example, stores the data on the filesystem.

                  1 of 1 people found this helpful