3 Replies Latest reply on Nov 17, 2016 12:40 PM by gordonc

    Unable to locate repository from command line Java application

    gordonc

      I have written a Java application that reads a filesystem based modeshape repository.

       

      The application locates the repository configuration file (UsageAnalyzer.json) in the same folder as the application. The config file contains:

      {

         "name" : "UsageAnalyzer",

         "workspaces" : {

            "predefined" : ["usageWorkspace"],

            "default" : "default",

            "allowCreation" : true

         },

         "security" : {

            "anonymous" : {

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

               "useOnFailedLogin" : false

            }

         },

         "storage": {

            "persistence" : {

               "type" : "file",

               "path": "UsageAnalyzer"

            }

         }

      }

       

      When running in Eclipse:

      - I have copied the config file into the target folder

      - this is the working directory for the code executing from the JAR file in that folder, and the code finds the config based on the working directory

      - I created the UsageAnalyzer folder, containing the modeshape.repository file, in the project root folder (ie "C:\projects\TreeViewer\UsageAnalyzer")

      - the application locates the config file properly and opens/reads the repository file properly

       

      Next I go to the command line in Windows:

      - copy the JAR file from the target folder (along with the config file) to a new temp folder

      - copy the UsageAnalyzer folder into the new folder

      - execute the following: java -cp .;TreeViewer-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.avaloncs.treeview.TreeViewer

       

      I get the following error:

      javax.jcr.RepositoryException: Error while starting 'UsageAnalyzer' repository: None of the existing persistence providers could return a Schematic DB with type 'file'

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

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

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

              at com.avaloncs.treeview.TreeViewer.getJcrRepositorySession(TreeViewer.java:216)

              at com.avaloncs.treeview.TreeViewer.initialize(TreeViewer.java:81)

              at com.avaloncs.treeview.TreeViewer.main(TreeViewer.java:334)

      Caused by: java.lang.RuntimeException: None of the existing persistence providers could return a Schematic DB with type 'file'

              at org.modeshape.schematic.Schematic.lambda$getDb$10(Schematic.java:81)

              at java.util.Optional.orElseThrow(Unknown Source)

              at org.modeshape.schematic.Schematic.getDb(Schematic.java:77)

              at org.modeshape.jcr.Environment.getDb(Environment.java:59)

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

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

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

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

              ... 5 more

       

      I have tried for many days to determine what is causing the error. I have even done remote debugging of the application, using the modeshape source.

      But I have not been able to figure this out.

       

      Does anyone have any suggestions that I can try?

      My requirement is that this application must be able to run from command line, with external configuration file and external modeshape repository file.