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

this.pathResolver null on macOS #33

Closed
jepsar opened this issue Dec 13, 2021 · 23 comments
Closed

this.pathResolver null on macOS #33

jepsar opened this issue Dec 13, 2021 · 23 comments
Labels
bug Something isn't working

Comments

@jepsar
Copy link

jepsar commented Dec 13, 2021

java.lang.NullPointerException: Cannot invoke "org.sonarsource.nodejs.BundlePathResolver.resolve(String)" because "this.pathResolver" is null
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.locateNodeOnMac(NodeCommandBuilderImpl.java:220)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.locateNode(NodeCommandBuilderImpl.java:208)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.retrieveNodeExecutableFromConfig(NodeCommandBuilderImpl.java:202)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:133)
	at com.github.philippefichet.sonarlint4netbeans.SonarLintEngineImpl.tryToSetDefaultNodeJS(SonarLintEngineImpl.java:135)
	at com.github.philippefichet.sonarlint4netbeans.SonarLintEngineImpl.lambda$createInternalEngine$2(SonarLintEngineImpl.java:122)
[catch] at java.base/java.lang.Thread.run(Thread.java:833)
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12)
OpenJDK 64-Bit Server VM Temurin-17.0.1+12 (build 17.0.1+12, mixed mode)
@philippefichet philippefichet added the bug Something isn't working label Dec 13, 2021
@jepsar
Copy link
Author

jepsar commented Dec 14, 2021

After reading #17 and a43b4df, this might be relevant:

Screenshot 2021-12-14 at 09 21 17

@philippefichet
Copy link
Owner

Hello and thank you for your issue :)
According to the stacktrace, the problem occurs on MacOS and is in "org.sonarsource.javascript:nodejs-utils", more precisely in the part that looks for NodeJS automatically.
Do you have NodeJS installed? If yes a temporary solution could be to fill in the "NodeJS path" (https://github.com/philippefichet/sonarlint4netbeans/blob/master/docs/OptionsSonarLintOptions.jpg)
I don't master MacOS, but do you know any solutions so I can test?

@jepsar
Copy link
Author

jepsar commented Dec 15, 2021

Yes, I have NodeJS installed (see screenshot above). When I try to add the path to the SonarLint options, I can't, because it is stuck "loading".

Screenshot 2021-12-15 at 11 58 59

/usr/local/bin/node -v
v14.15.4

@jepsar jepsar changed the title this.pathResolver null on NB 12.6 + JDK 17 this.pathResolver null on NB 12.6 + JDK 17 on macOS Dec 15, 2021
@jepsar
Copy link
Author

jepsar commented Dec 15, 2021

@philippefichet can I put that path in a config file? I found this file in my previous NB installation:

/Users/jasper/Library/Application Support/NetBeans/12.5/config/Modules/com-github-philippefichet-sonarlint4netbeans.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//NetBeans//DTD Module Status 1.0//EN"
                        "http://www.netbeans.org/dtds/module-status-1_0.dtd">
<module name="com.github.philippefichet.sonarlint4netbeans">
    <param name="autoload">false</param>
    <param name="eager">false</param>
    <param name="enabled">true</param>
    <param name="jar">modules/com-github-philippefichet-sonarlint4netbeans.jar</param>
    <param name="reloadable">false</param>
</module>

@philippefichet
Copy link
Owner

I didn't understand the screenshot like that, OK.
For the "com-github-philippefichet-sonarlint4netbeans.xml" file, I think that's the information for Netbeans to use my plugin.
Another troubleshooting solution would be to edit the file config/Preferences/com/github/philippefichet/sonarlint4netbeans.properties present in the netbeans user directory (Menu Help -> About -> "User directory") by adding :

runtime.nodejs.path=/usr/local/bin/node
runtime.nodejs.version=14.15.4

And to fix the problem at the root I think we will have to implement the interface "org.sonarsource.nodejs.BundlePathResolver".

@jepsar
Copy link
Author

jepsar commented Dec 15, 2021

Great, thank you! That workaround is working for me.

@jepsar jepsar changed the title this.pathResolver null on NB 12.6 + JDK 17 on macOS this.pathResolver null on macOS Dec 15, 2021
@philippefichet
Copy link
Owner

Good news :),
As soon as I have more time I will correct it properly ;).
Thank you again for your issue :)

@jepsar
Copy link
Author

jepsar commented Dec 16, 2021

Thanks again. Happy to test any changes.

@screamnAbdab
Copy link

Thank you phiippefichet and jepsar for identifying and providing a workaround for this issue. Plugin now works for me on mac as well. Much appreciated.

@philippefichet
Copy link
Owner

I think I fixed this error in the "fix-npe-nodejs-macos" branch, but I could only use github actions to check.
Could someone test and do back in a graphical environment if you please?
Thanks in advance :)

@jepsar
Copy link
Author

jepsar commented Feb 28, 2022

Is there a release I can test?

@philippefichet
Copy link
Owner

No, the patch is just on a branch but I could do a build if needed

@jepsar
Copy link
Author

jepsar commented Mar 1, 2022

That would be great. The only thing I should do is disable runtime.nodejs.path=... in sonarlint4netbeans.properties, right?

@philippefichet
Copy link
Owner

Here is the nbm file of the pre release with the patch.
Yes, you have to remove "runtime.nodejs.path=..." and "runtime.nodejs.version=..." to test.
Thanks again :)

@jepsar
Copy link
Author

jepsar commented Mar 2, 2022

I'm getting

java.lang.NullPointerException
	at java.base/java.io.File.<init>(File.java:278)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.locateNodeOnMac(NodeCommandBuilderImpl.java:221)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.locateNode(NodeCommandBuilderImpl.java:208)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.retrieveNodeExecutableFromConfig(NodeCommandBuilderImpl.java:202)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:133)
	at com.github.philippefichet.sonarlint4netbeans.SonarLintUtils.tryToSearchDefaultNodeJS(SonarLintUtils.java:690)
	at com.github.philippefichet.sonarlint4netbeans.SonarLintEngineImpl.tryToSetDefaultNodeJS(SonarLintEngineImpl.java:118)
	at com.github.philippefichet.sonarlint4netbeans.SonarLintEngineImpl.lambda$createInternalEngine$1(SonarLintEngineImpl.java:109)
[catch] at java.base/java.lang.Thread.run(Thread.java:833)

@philippefichet
Copy link
Owner

Thank you for your test.
I will rework my patch, thanks again :)

@philippefichet
Copy link
Owner

I think I have solved the NullPointerException problem.
However, the "PATH" environment variable defined in bash (or other) does not seem to be passed to the GUI (via Dock).
Searching for the default nodejs installation will not be fully functional, but manual entry should work :)
I uploaded the new version of the plugin here.
@jepsar Could you test and give me feedback in a graphical environment please?
Thanks in advance.

@jepsar
Copy link
Author

jepsar commented Mar 14, 2022

Your link points to a release done 13 days ago. Is it correct?

@philippefichet
Copy link
Owner

Yes, I just re-uploaded the .nbm

@jepsar
Copy link
Author

jepsar commented Mar 15, 2022

I'm able to access the plugin options now, so that's an improvement. However, I do get:

org.sonarsource.nodejs.NodeCommandException: Default Node.js executable for MacOS does not exist.
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.locateNodeOnMac(NodeCommandBuilderImpl.java:224)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.locateNode(NodeCommandBuilderImpl.java:208)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.retrieveNodeExecutableFromConfig(NodeCommandBuilderImpl.java:202)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:133)
[catch] at com.github.philippefichet.sonarlint4netbeans.SonarLintUtils.tryToSearchDefaultNodeJS(SonarLintUtils.java:690)
	at com.github.philippefichet.sonarlint4netbeans.SonarLintEngineImpl.tryToSetDefaultNodeJS(SonarLintEngineImpl.java:118)
	at com.github.philippefichet.sonarlint4netbeans.SonarLintEngineImpl.lambda$createInternalEngine$1(SonarLintEngineImpl.java:109)
	at java.base/java.lang.Thread.run(Thread.java:833)

@philippefichet
Copy link
Owner

@jepsar Thanks again for your tests :)
Does this Exception appear in a notification at the bottom or just in the logs? (View > IDE Log)

@jepsar
Copy link
Author

jepsar commented Mar 16, 2022

In the notifications.

@philippefichet
Copy link
Owner

Thanks @jepsar, I managed to reproduce this mistake and correct it :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants