Hello, I've been using JackRabbit and Oak with a Mongo database for the past 
few months. I am using spring boot + gradle to build the executable jar with 
the following dependencies:
    // 
https://mvnrepository.com/artifact/org.apache.jackrabbit/oak-store-document
    compile group: 'org.apache.jackrabbit', name: 'oak-store-document', 
version: '1.18.0'
    // https://mvnrepository.com/artifact/org.apache.jackrabbit/oak-segment
    compile group: 'org.apache.jackrabbit', name: 'oak-segment', version: 
'1.6.18'
    // https://mvnrepository.com/artifact/org.apache.jackrabbit/oak-core
    compile group: 'org.apache.jackrabbit', name: 'oak-core', version: '1.18.0'
    // https://mvnrepository.com/artifact/org.apache.jackrabbit/oak-jcr
    compile group: 'org.apache.jackrabbit', name: 'oak-jcr', version: '1.18.0'
So far I've been using a Mongo database but I have to move to a file system 
store. I have used the code below, however I noticed that when the server is 
restarted I lose all indices and the nodes I have added (the physical data is 
still on the disk though). I didn't have this issue with Mongo. 

    @PostConstruct
    public void initialise() throws LoginException, RepositoryException {
        fileDataStore = new FileDataStore();
        final String string = "c:/java/jrc_repo";
        fileDataStore.init(string);
        fileDataStore.setPath(string);
        final DataStoreBlobStore dataStoreBlobStore = new 
DataStoreBlobStore(fileDataStore, true);

        final DocumentNodeStoreBuilder<?> documentNodeStoreBuilder = 
DocumentNodeStoreBuilder.newDocumentNodeStoreBuilder();
        documentNodeStoreBuilder.setBlobStore(dataStoreBlobStore);

        store = documentNodeStoreBuilder.build();
        repository = new Jcr(new Oak(store)).createRepository();
        session = repository.login(new SimpleCredentials(username, 
password.toCharArray()));
    }

    @PreDestroy
    public void close() {
        if (repository instanceof JackrabbitRepository) {
            session.logout();
            fileDataStore.close();
            store.dispose();
            ((JackrabbitRepository) repository).shutdown();
        }
    }
Can anyone think of anything I could be doing wrong? Is there any sample code 
on how to use a file data store?
Regards
Panos

Reply via email to