Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open local DB when notes client isn't started #76

Open
beranPro opened this issue Aug 1, 2022 · 4 comments
Open

Unable to open local DB when notes client isn't started #76

beranPro opened this issue Aug 1, 2022 · 4 comments

Comments

@beranPro
Copy link

beranPro commented Aug 1, 2022

Hi,
i'm currently building a standalone application which uses domino jna for replicating local DBs and i experienced that i'm not able to open a database until i open up the notes client. Is this really necessary or i'm doing the session initialization wrong? Are there multiple ways to create a notes session maybe with different consequences?

here the simplified code:

    public boolean replicate(Request newReplication) {
        final boolean ret = false;
        final List<NotesReplicationStats> replicationStats = new ArrayList<>();
        EnumSet<ReplicateOption> replOptions = EnumSet.noneOf(ReplicateOption.class);
        replOptions.add(ReplicateOption.RECEIVE_NOTES);
        replOptions.add(ReplicateOption.SEND_NOTES);
        replOptions.add(ReplicateOption.CLOSE_SESSION);

        try {

            //initial Notes/Domino access for current thread (running single-threaded here)
            NotesThread.sinitThread();

            //launch run method within runWithAutoGC block to let it collect/dispose C handles
            NotesGC.runWithAutoGC(new Callable<Object>() {

                public Object call() throws Exception {
                    boolean dontSetEnvVar = true;
                    IDUtils.switchToId(notesId, notesIdPass, dontSetEnvVar);

                    for (Job job : newReplication.getJobs()) {
                        try {

                            if( NotesDatabase.exists("", job.getPath()) ) { //Check if DB exists in local (returns false if notes client isn't open)
                                NotesDatabase dbNames = new NotesDatabase("", job.getPath(), "");
                                NotesReplicationStats nrs = dbNames.replicateWithServer(job.getServer(), replOptions, 10);
                                dbNames.recycle();
                            } else {
                                logger.error("couldn't open DB");
                            }

                        } catch (Exception e) {
                            logger.error("couldn't open DB");
                        }
                    }
                    return new Object();
                }

            });
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            //terminate Notes/Domino access for current thread
            NotesThread.stermThread();
        }
        return true;
    }

I'm pretty sure i'm doing something wrong here.

@beranPro beranPro changed the title Different ways to create NotesSessions Unable to open local DB when notes client isn't started Aug 1, 2022
@klehmann
Copy link
Owner

klehmann commented Aug 1, 2022

Looks ok. Which error do you get and which OS are you using?

@beranPro
Copy link
Author

beranPro commented Aug 1, 2022

i tried it with a current Windows 10 x64 and Notes 12 (x86) and with a Windows 7 x86 and a Notes 9 Client x86.
I'm using the static "exists" method to check if the local replica exists and when i have no notes apps running he returns false

https://github.com/klehmann/domino-jna/blob/master/domino-jna/src/main/java/com/mindoo/domino/jna/NotesDatabase.java#L241

When i start my notes client and execute the same stuff again it works.

@beranPro
Copy link
Author

beranPro commented Aug 3, 2022

Hi @klehmann ,
it seems that the NotesDatabases.exists() method is the problem. When i don't call this and open the DB directly then it works.

@klehmann
Copy link
Owner

klehmann commented Aug 3, 2022

Thanks for the info. Looks like the Notes Client does not have modified dates of a database if it's not already open.
That method uses NSFDbModifiedTimeByName internally. Somehow this rings a bell but I cannot remember in which context I noticed this before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants