koppor / jabref

Collection of simple for JabRef issues. Please submit PRs to https://github.com/jabRef/jabref/.
https://github.com/jabRef/jabref/
MIT License
8 stars 13 forks source link

Enable running Launcher from IntelliJ #635

Closed koppor closed 1 year ago

koppor commented 1 year ago

While working on https://github.com/JabRef/jabref/pull/9355 (a refined guide for IntelliJ), I found out, that it is not possible to start Launcher.

This PR outlines fixes. I think, these are all wrong, because, IntelliJ IDEA - getClass().getResource("...") return null.


When starting from IntelliJ using Launcher, I get following exception:

Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <*> at index 53: C:\Users\koppor\AppData\Local\org.jabref\jabref\Logs\*unknown*
    at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
    at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
    at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
    at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
    at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
    at java.base/java.nio.file.Path.of(Path.java:147)
    at org.jabref/org.jabref.cli.Launcher.addLogToDisk(Launcher.java:94)
    at org.jabref/org.jabref.cli.Launcher.main(Launcher.java:51)

I traced it down to following code

public static final String UNKNOWN_VERSION = "*unknown*";

I removed the starts and now JabRef runs.


Then, I got a bunch of exception, because .class.getResource(...) is always null at IntelliJ. I tried solutions from https://stackoverflow.com/q/26328040/873282. The main solutions were

However, then I would have had to prefix each filename with the package name path. This is IMHO unreadable. So, I skipped and will try to create an MWE and file an IntelliJ issue.

Notes:

ERROR: Unexpected exception: java.lang.NullPointerException: Cannot invoke "java.net.URL.toURI()" because the return value of "java.lang.Class.getResource(String)" is null
    at org.jabref/org.jabref.logic.net.ssl.TrustStoreManager.createTruststoreFileIfNotExist(TrustStoreManager.java:142)
    at org.jabref/org.jabref.cli.Launcher.configureSSL(Launcher.java:174)
    at org.jabref/org.jabref.cli.Launcher.main(Launcher.java:65)
...
ERROR: Unexpected exception: java.lang.NullPointerException
    at java.base/java.util.Objects.requireNonNull(Objects.java:208)
    at java.base/java.nio.file.Files.copy(Files.java:3129)
    at org.jabref/org.jabref.logic.journals.JournalAbbreviationLoader.loadRepository(JournalAbbreviationLoader.java:30)
    at org.jabref/org.jabref.cli.Launcher.applyPreferences(Launcher.java:144)
    at org.jabref/org.jabref.cli.Launcher.main(Launcher.java:66)
koppor commented 1 year ago

We found another way. See https://github.com/JabRef/jabref/pull/10323.

koppor commented 1 year ago

The IntelliJ issue is https://youtrack.jetbrains.com/issue/IDEA-119280.

We still need to craft an MWE as reproducer.

The issue is that in a module, only the first classpath is searched. IntelliJ puts the classes out directory, before the resources out directory, which is then not searched.