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

Enable running Launcher from IntelliJ #635

Closed
wants to merge 2 commits into from
Closed

Enable running Launcher from IntelliJ #635

wants to merge 2 commits into from

Conversation

koppor
Copy link
Owner

@koppor koppor commented Nov 6, 2022

While working on JabRef#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

  • Use getClassLoader
  • Do NOT prefix the filname with /.

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
Copy link
Owner Author

koppor commented Sep 21, 2023

We found another way. See JabRef#10323.

@koppor koppor closed this Sep 21, 2023
@koppor
Copy link
Owner Author

koppor commented Sep 21, 2023

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.

@koppor koppor deleted the fix-startup branch January 9, 2024 20:59
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

Successfully merging this pull request may close these issues.

1 participant