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

Clicking 'Get fulltext' triggers a 'null pointer exception' when a databse is opened in a current directory. #2739

Closed
sauliusg opened this issue Apr 14, 2017 · 2 comments

Comments

@sauliusg
Copy link
Contributor

sauliusg commented Apr 14, 2017

JabRef version JabRef 3.8.2 and JabRef 4.0.0-dev (master commit e7fc94c), running on 4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux, LinuxMin 18.1, openjdk version "1.8.0_121", triggers "Null pointer exception" when database is opened in the current directory, with no explicit path.

Steps to reproduce (using stock 'bash' on LinuxMint):

mkdir -p ~/tmp/jabref/pdf; cd ~/tmp/jabref

touch pdf/Feringa1983.pdf

jabref &

# Options|Preferences|File: remove the tick from "Open last edited databases at startup"
4a. Set "Main file directory" to "/home/saulius/tmp/jabref" (replace "saulius" with your login name)

Exit from Jabref

unpack the attached "bibliography.bib" (from the attached "bibliography.zip", contains just one entry) to the working directory;

jabref bibliography.bib

Edit the entry; go to "General"; remove the file; click "Get fulltext"
=> the java.lang.NullPointerException: null is thrown (see the log below)

screenshot from 2017-04-14 22-45-45
bibliography.zip

the GUI can be closed normally.

If a database is opened using menus, "File|Open Database|...", the current master works as expected.

An excerpt of the log file here:
saulius@kolibris Feringa/ $ JabRef bibliography.bib &
[3] 16038
saulius@kolibris Feringa/ $ AI: INFO 14-04-2017 22:45, 11: Configuration file has been successfully found as resource
AI: INFO 14-04-2017 22:45, 11: 'MaxTelemetryBufferCapacity': null value is replaced with '500'
AI: INFO 14-04-2017 22:45, 11: 'FlushIntervalInSeconds': null value is replaced with '5'
AI: TRACE 14-04-2017 22:45, 11: Using Http Client version 4.3+
AI: INFO 14-04-2017 22:45, 11: 'Channel.MaxTransmissionStorageCapacityInMB': null value is replaced with '10'
AI: INFO 14-04-2017 22:45, 11: Configuration file has been successfully found as resource
AI: INFO 14-04-2017 22:45, 11: 'MaxTelemetryBufferCapacity': null value is replaced with '500'
AI: INFO 14-04-2017 22:45, 11: 'FlushIntervalInSeconds': null value is replaced with '5'
AI: INFO 14-04-2017 22:45, 11: 'Channel.MaxTransmissionStorageCapacityInMB': null value is replaced with '10'
AI: TRACE 14-04-2017 22:45, 23: Telemetry Configuration: instrumentation key 'null' is not in UUID format
AI: TRACE 14-04-2017 22:45, 23: Telemetry Configuration: illegal instrumentation key: null
22:45:30.349 [AWT-EventQueue-0] INFO  org.jabref.logic.importer.OpenDatabase - Opening: bibliography.bib
22:45:30.406 [AWT-EventQueue-0] WARN  org.jabref.JabRefGUI - There seem to be problems with OpenJDK and the default GTK Look&Feel. Using Metal L&F instead. Change to another L&F with caution.
File: grouptree.fxml not found, attempting with camel case
Apr 14, 2017 10:45:31 PM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 8.0.112 by JavaFX runtime of version 8.0.60
File: grouptree.css not found, attempting with camel case
22:45:37.539 [AWT-EventQueue-0] WARN  org.jabref.gui.date.DatePickerButton - Unable to parse stored date for field 'date' with current settings. Clear button in calender popup will not work.
22:45:42.125 [JabRef CachedThreadPool] ERROR org.jabref.FallbackExceptionHandler - Uncaught exception Occurred in Thread[JabRef CachedThreadPool,6,main]
java.lang.NullPointerException: null
	at org.jabref.model.database.BibDatabaseContext.lambda$getFileDirectories$4(BibDatabaseContext.java:201) ~[JabRef-4.0.0-dev.jar:?]
	at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_121]
	at org.jabref.model.database.BibDatabaseContext.getFileDirectories(BibDatabaseContext.java:200) ~[JabRef-4.0.0-dev.jar:?]
	at org.jabref.model.database.BibDatabaseContext.getFileDirectories(BibDatabaseContext.java:148) ~[JabRef-4.0.0-dev.jar:?]
	at org.jabref.gui.externalfiles.AutoSetLinks$1.run(AutoSetLinks.java:103) ~[JabRef-4.0.0-dev.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
AI: TRACE 14-04-2017 22:45, 42: Telemetry Configuration: illegal instrumentation key: null

@sauliusg
Copy link
Contributor Author

sauliusg commented Apr 14, 2017

The reason seems to be in the public List getFileDirectories(String fieldName, FileDirectoryPreferences preferences) method (BibDatabaseContext.java:171), line 'String parentDir = dbPath.getParent().toAbsolutePath().toString();' -- when a database is opened as 'bibliography.bib', the dbPath.getParent() is null. Below is the output from my branch ([email protected]:sauliusg/jabref.git, fix-2700-null-pointer-exception-on-Get-fulltext fa84e4e Adding a bunch of debug prints...) with debug prints. I think I can pin down the reason and offer a fix tomorrow... vis.:

saulius@kolibris Feringa/ $ JAVA_OPTS=-ea JabRef bibliography.bib &
[3] 17726
saulius@kolibris Feringa/ $ AI: INFO 14-04-2017 22:53, 11: Configuration file has been successfully found as resource
AI: INFO 14-04-2017 22:53, 11: 'MaxTelemetryBufferCapacity': null value is replaced with '500'
AI: INFO 14-04-2017 22:53, 11: 'FlushIntervalInSeconds': null value is replaced with '5'
AI: TRACE 14-04-2017 22:53, 11: Using Http Client version 4.3+
AI: INFO 14-04-2017 22:53, 11: 'Channel.MaxTransmissionStorageCapacityInMB': null value is replaced with '10'
AI: INFO 14-04-2017 22:53, 11: Configuration file has been successfully found as resource
AI: INFO 14-04-2017 22:53, 11: 'MaxTelemetryBufferCapacity': null value is replaced with '500'
AI: INFO 14-04-2017 22:53, 11: 'FlushIntervalInSeconds': null value is replaced with '5'
AI: INFO 14-04-2017 22:53, 11: 'Channel.MaxTransmissionStorageCapacityInMB': null value is replaced with '10'
AI: TRACE 14-04-2017 22:53, 23: Telemetry Configuration: instrumentation key 'null' is not in UUID format
AI: TRACE 14-04-2017 22:53, 23: Telemetry Configuration: illegal instrumentation key: null
22:53:04.223 [AWT-EventQueue-0] INFO  org.jabref.logic.importer.OpenDatabase - Opening: bibliography.bib
22:53:04.300 [AWT-EventQueue-0] WARN  org.jabref.JabRefGUI - There seem to be problems with OpenJDK and the default GTK Look&Feel. Using Metal L&F instead. Change to another L&F with caution.
File: grouptree.fxml not found, attempting with camel case
Apr 14, 2017 10:53:05 PM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 8.0.112 by JavaFX runtime of version 8.0.60
File: grouptree.css not found, attempting with camel case
22:53:09.957 [AWT-EventQueue-0] WARN  org.jabref.gui.date.DatePickerButton - Unable to parse stored date for field 'date' with current settings. Clear button in calender popup will not work.
>>> HERE!
EEE>>> dbPath is NOT null: bibliography.bib
22:53:14.596 [JabRef CachedThreadPool] ERROR org.jabref.FallbackExceptionHandler - Uncaught exception Occurred in Thread[JabRef CachedThreadPool,6,main]
java.lang.AssertionError: dbPath.getParent() is null
	at org.jabref.model.database.BibDatabaseContext.lambda$getFileDirectories$4(BibDatabaseContext.java:209) ~[JabRef-4.0.0-dev.jar:?]
	at java.util.Optional.ifPresent(Optional.java:159) ~[?:1.8.0_121]
	at org.jabref.model.database.BibDatabaseContext.getFileDirectories(BibDatabaseContext.java:202) ~[JabRef-4.0.0-dev.jar:?]
	at org.jabref.model.database.BibDatabaseContext.getFileDirectories(BibDatabaseContext.java:148) ~[JabRef-4.0.0-dev.jar:?]
	at org.jabref.gui.externalfiles.AutoSetLinks$1.run(AutoSetLinks.java:103) ~[JabRef-4.0.0-dev.jar:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
AI: TRACE 14-04-2017 22:53, 42: Telemetry Configuration: illegal instrumentation key: null

@sauliusg sauliusg reopened this Apr 14, 2017
@sauliusg
Copy link
Contributor Author

Was closed by mistake, reopening.

@sauliusg sauliusg changed the title Clicking 'Get fulltext' triggers a 'null pointer exception' when a databse is opened in a current directory. [WIP] Clicking 'Get fulltext' triggers a 'null pointer exception' when a databse is opened in a current directory. Apr 14, 2017
@koppor koppor changed the title [WIP] Clicking 'Get fulltext' triggers a 'null pointer exception' when a databse is opened in a current directory. Clicking 'Get fulltext' triggers a 'null pointer exception' when a databse is opened in a current directory. Apr 16, 2017
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