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

Saving file throws exception #6102

Closed
Tracked by #8750
ilippert opened this issue Mar 11, 2020 · 11 comments · Fixed by #9067
Closed
Tracked by #8750

Saving file throws exception #6102

ilippert opened this issue Mar 11, 2020 · 11 comments · Fixed by #9067
Assignees
Labels
bug Confirmed bugs or reports that are very likely to be bugs export / save
Milestone

Comments

@ilippert
Copy link

ilippert commented Mar 11, 2020

I saved my file, and got this exception. I cannot repeat this.

JabRef 5.0--2020-03-09--6bff936
Linux 5.5.8-200.fc31.x86_64 amd64
Java 13.0.2

Inspired by the discussion at #4877 I like to contribute the fact that my file system is a LVM partition with a cache.

Caused by: java.nio.file.NoSuchFileException: /home/ilippert/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib.tmp -> /home/ilippert/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib at
Log File org.jabref.logic.exporter.SaveException: Problems saving: at org.jabref/org.jabref.gui.exporter.SaveDatabaseAction.saveDatabase(Unknown Source) at org.jabref/org.jabref.gui.exporter.SaveDatabaseAction.doSave(Unknown Source) at org.jabref/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source) at org.jabref/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source) at org.jabref/org.jabref.gui.exporter.SaveAction.execute(Unknown Source) at org.jabref/org.jabref.gui.actions.JabRefAction.lambda$new$2(Unknown Source) at org.jabref.merged.module/org.controlsfx.control.action.Action.handle(Unknown Source) at org.jabref.merged.module/org.controlsfx.control.action.Action.handle(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at org.jabref.merged.module/javafx.event.Event.fireEvent(Unknown Source) at org.jabref.merged.module/javafx.scene.control.MenuItem.fire(Unknown Source) at org.jabref.merged.module/com.sun.javafx.scene.control.ControlAcceleratorSupport.lambda$doAcceleratorInstall$1(Unknown Source) at org.jabref.merged.module/com.sun.javafx.scene.KeyboardShortcutsHandler.processAccelerators(Unknown Source) at org.jabref.merged.module/com.sun.javafx.scene.KeyboardShortcutsHandler.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at org.jabref.merged.module/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at org.jabref.merged.module/javafx.event.Event.fireEvent(Unknown Source) at org.jabref.merged.module/javafx.scene.Scene$KeyHandler.process(Unknown Source) at org.jabref.merged.module/javafx.scene.Scene.processKeyEvent(Unknown Source) at org.jabref.merged.module/javafx.scene.Scene$ScenePeerListener.keyEvent(Unknown Source) at org.jabref.merged.module/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(Unknown Source) at org.jabref.merged.module/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at org.jabref.merged.module/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(Unknown Source) at org.jabref.merged.module/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source) at org.jabref.merged.module/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(Unknown Source) at org.jabref.merged.module/com.sun.glass.ui.View.handleKeyEvent(Unknown Source) at org.jabref.merged.module/com.sun.glass.ui.View.notifyKey(Unknown Source) at org.jabref.merged.module/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at org.jabref.merged.module/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.nio.file.NoSuchFileException: /home/ilippert/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib.tmp -> /home/ilippert/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source) at java.base/sun.nio.fs.UnixCopyFile.move(Unknown Source) at java.base/sun.nio.fs.UnixFileSystemProvider.move(Unknown Source) at java.base/java.nio.file.Files.move(Unknown Source) at org.jabref/org.jabref.logic.exporter.AtomicFileOutputStream.close(Unknown Source) at java.base/sun.nio.cs.StreamEncoder.implClose(Unknown Source) at java.base/sun.nio.cs.StreamEncoder.close(Unknown Source) at java.base/java.io.OutputStreamWriter.close(Unknown Source) at org.jabref/org.jabref.logic.exporter.BibDatabaseWriter.savePartOfDatabase(Unknown Source) at org.jabref/org.jabref.logic.exporter.BibDatabaseWriter.saveDatabase(Unknown Source) ... 42 more
@koppor
Copy link
Member

koppor commented Mar 12, 2020

Could the file be saved at the end or is it corrupted?

@ilippert
Copy link
Author

ilippert commented Mar 12, 2020 via email

@stefan-kolb stefan-kolb added the bug Confirmed bugs or reports that are very likely to be bugs label Mar 14, 2020
@koppor koppor added this to Normal priority in Bugs via automation Apr 3, 2020
@koppor koppor moved this from Normal priority to Low priority in Bugs Apr 3, 2020
@ilippert
Copy link
Author

ilippert commented Apr 15, 2020

I have not experienced the issue for a long time anymore

JabRef 5.1--2020-04-14--e86d415
Linux 5.5.15-200.fc31.x86_64 amd64
Java 14.0.1

@ilippert
Copy link
Author

these days I have been seeing the phenomenon again - the same as in #4877 (comment) I guess?

@Siedlerchr
Copy link
Member

Siedlerchr commented Jul 12, 2020

The problem lies here:

Files.move(temporaryFile, targetFile, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);

And I finally found the root cause. It's a threading problem when you have austosave enabled and at the same time manually hit save.
The Autosave Backup manager also calls the writer.close method, through a different path.
The problem is that the backup manager invokes this method in

We somehow need a way to lock that or cancel the save operation when already one is active. The other problem is that always a new object instance of the Writer or Save Action is created. I tried some locking in the cleanup
@koppor @tobiasdiez any ideas?
File based locking will not work on unix.

@tobiasdiez
Copy link
Member

What about writing to a unique temporary file (in the users temporary file folder, with some random name)? Then you don't need to worry about locking etc (since the move command is atomic).

Moreover, I think, it's time to finally remove the BackupManager stuff...simply make a copy of the bib file upon loading a library (and say keep the last 10 versions). We run into so many problems with the backup stuff and it's a pretty old concept anyway.

@ilippert
Copy link
Author

I see mozilla and others simply writing to /tmp/ - i do not know whether that is possible for all unixes. but it would make sense to me.

in case the BackupManager is to keep x versions, I would say: let the user define x. I suggest so because many users will have already other backup/versioning software and might constrain x to 1; and other might like a higher number of backup versions.

@Siedlerchr Siedlerchr moved this from Low priority to High priority in Bugs Jul 17, 2020
@Siedlerchr Siedlerchr added this to the v5.1 milestone Jul 17, 2020
@Siedlerchr
Copy link
Member

@tobiasdiez The backup manager is not that problem it's the autosave manager.
change anything in a field. Autosave is triggered. Now hit a manual save repeatedly
The autosave manager also calls the writer.close in the savePartOfDatabase which then triggers the file moving. However, as it's a move, the original file is already moved.

I also discovered an issue with the FileOutputStream locking. Trying to check that

@tobiasdiez
Copy link
Member

Yeah I understand, that's why I suggested that every write process should have their own temporary file.

@koppor koppor modified the milestones: v5.1, v5.2 Jul 27, 2020
@koppor koppor added this to backlog in JabRef Maintainers' Focus Sep 26, 2020
@koppor koppor modified the milestones: v5.2, v5.3 Dec 7, 2020
@calixtus calixtus moved this from backlog to jabref contributor working on it in JabRef Maintainers' Focus Feb 15, 2021
@koppor koppor modified the milestones: v5.3, v5.4 Jun 7, 2021
@koppor koppor moved this from jabref contributor working on it to backlog in JabRef Maintainers' Focus Jun 21, 2021
@ilippert
Copy link
Author

ilippert commented Aug 8, 2021

JabRef 5.3--2021-07-16--c99d61c
Linux 5.13.7-200.fc34.x86_64 amd64
Java 16.0.1
JavaFX 16+8

Let me add this exception I got a moment ago - might be related

Log File org.jabref.logic.exporter.SaveException: Problems saving: java.nio.file.NoSuchFileException: /home/il/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib.tmp -> /home/il/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib at org.jabref@5.3.21/org.jabref.gui.exporter.SaveDatabaseAction.saveDatabase(Unknown Source) at org.jabref@5.3.21/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source) at org.jabref@5.3.21/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source) at org.jabref@5.3.21/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source) at org.jabref@5.3.21/org.jabref.gui.exporter.SaveAction.execute(Unknown Source) at org.jabref@5.3.21/org.jabref.gui.actions.JabRefAction.lambda$new$3(Unknown Source) at org.jabref.merged.module@5.3.21/org.controlsfx.control.action.Action.handle(Unknown Source) at org.jabref.merged.module@5.3.21/org.controlsfx.control.action.Action.handle(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at org.jabref.merged.module@5.3.21/javafx.event.Event.fireEvent(Unknown Source) at org.jabref.merged.module@5.3.21/javafx.scene.control.MenuItem.fire(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.scene.control.ControlAcceleratorSupport.lambda$doAcceleratorInstall$1(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.scene.KeyboardShortcutsHandler.processAccelerators(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.scene.KeyboardShortcutsHandler.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source) at org.jabref.merged.module@5.3.21/javafx.event.Event.fireEvent(Unknown Source) at org.jabref.merged.module@5.3.21/javafx.scene.Scene$KeyHandler.process(Unknown Source) at org.jabref.merged.module@5.3.21/javafx.scene.Scene.processKeyEvent(Unknown Source) at org.jabref.merged.module@5.3.21/javafx.scene.Scene$ScenePeerListener.keyEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.tk.quantum.GlassViewEventHandler$KeyEventNotification.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleKeyEvent$1(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.glass.ui.View.handleKeyEvent(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.glass.ui.View.notifyKey(Unknown Source) at org.jabref.merged.module@5.3.21/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at org.jabref.merged.module@5.3.21/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.nio.file.NoSuchFileException: /home/il/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib.tmp -> /home/il/Documents/Studies/Publications&Products/Resources/Literature-bibtex.bib at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source) at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source) at java.base/sun.nio.fs.UnixCopyFile.move(Unknown Source) at java.base/sun.nio.fs.UnixFileSystemProvider.move(Unknown Source) at java.base/java.nio.file.Files.move(Unknown Source) at org.jabref@5.3.21/org.jabref.logic.exporter.AtomicFileOutputStream.close(Unknown Source) at java.base/sun.nio.cs.StreamEncoder.implClose(Unknown Source) at java.base/sun.nio.cs.StreamEncoder.close(Unknown Source) at java.base/java.io.OutputStreamWriter.close(Unknown Source) at org.jabref@5.3.21/org.jabref.logic.exporter.BibDatabaseWriter.savePartOfDatabase(Unknown Source) at org.jabref@5.3.21/org.jabref.logic.exporter.BibDatabaseWriter.saveDatabase(Unknown Source) ... 42 more

@koppor koppor assigned koppor and unassigned Siedlerchr Aug 16, 2021
@CouldBeThis
Copy link

CouldBeThis commented Aug 26, 2021

Hi, I thought I would let you know that I was having a similar error but I managed to fix it.

I was creating a new library. The problem in my case was that I had an emoji (🌱) in path of "main file directory". There is an & still in the directory name with no issue.

(You will think that using emojis in file names is a stupid thing to do but I am a very visual person and having cues makes using the computer much, much easier especially when in the command line. It causes surprisingly few problems but occasionally there is something. Especially with non-native applications.)

Although it doesn't look like the others above do such ridiculous things as I do, maybe it'll be some kind of useful hint.

Thanks for the software. :)

org.jabref.logic.exporter.SaveException: Problems saving: java.nio.file.NoSuchFileException: /Volumes/HDD02/Files/� Writing & Research/_JabRef/_BibFiles/Untitled..bib.tmp
	at org.jabref@5.3.60000/org.jabref.gui.exporter.SaveDatabaseAction.saveDatabase(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.gui.exporter.SaveDatabaseAction.saveAs(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.gui.exporter.SaveDatabaseAction.save(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.gui.exporter.SaveAction.execute(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.gui.actions.JabRefAction.lambda$new$3(Unknown Source)
	at org.jabref.merged.module@5.3.60000/org.controlsfx.control.action.Action.handle(Unknown Source)
	at org.jabref.merged.module@5.3.60000/org.controlsfx.control.action.Action.handle(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/javafx.event.Event.fireEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/javafx.scene.control.MenuItem.fire(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.scene.control.GlobalMenuAdapter.lambda$bindMenuItemProperties$2(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/javafx.event.Event.fireEvent(Unknown Source)
	at org.jabref.merged.module@5.3.60000/javafx.scene.control.MenuItem.fire(Unknown Source)
	at org.jabref.merged.module@5.3.60000/com.sun.javafx.tk.quantum.GlassSystemMenu$1.action(Unknown Source)
Caused by: java.nio.file.NoSuchFileException: /Volumes/HDD02/Files/� Writing & Research/_JabRef/_BibFiles/Untitled..bib.tmp
	at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(Unknown Source)
	at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
	at java.base/java.nio.file.Files.newOutputStream(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.logic.exporter.AtomicFileOutputStream.<init>(Unknown Source)
	at org.jabref@5.3.60000/org.jabref.logic.exporter.AtomicFileWriter.<init>(Unknown Source)
	... 29 more

JabRef 5.3--2021-07-05--50c96a2
Mac OS X 10.14.6 x86_64
Java 16.0.1
JavaFX 16+8


Edit: I was closing the tabs from solving this problem and noticed noticed one I had opened from a search but didn't get to reading: Problem Saving Library - Help - Forum - JabRef

the real cause is a bit hidden in the log:

You have a missing opening curly brace somewhere in this entry:

Error in field ‘TITLE of entry Urpietal2016’: Unescaped ‘}’ character without opening bracket ends string prematurely. Field value: Dynamic simulation of CO{_2}-injection-induced fault rupture with slip-rate dependent friction coefficient

which sounds similar.

@koppor koppor modified the milestones: v5.4, v6.0 Dec 6, 2021
@koppor koppor modified the milestones: v6.0, v5.6 Feb 18, 2022
@koppor koppor modified the milestones: v5.6, v5.7 Mar 28, 2022
@koppor koppor mentioned this issue May 2, 2022
14 tasks
@ThiloteE ThiloteE modified the milestones: v5.7, v5.8 Jul 14, 2022
Bugs automation moved this from High priority to Done Aug 16, 2022
JabRef Maintainers' Focus automation moved this from backlog to done (merged into master) Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs export / save
Projects
Archived in project
Bugs
  
Done
JabRef Maintainers' Focus
  
done (merged into master)
7 participants