microsoft / vscode-java-dependency

Manage Java projects in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-dependency
MIT License
152 stars 74 forks source link

Java explorer don't show .java files #793

Closed Raidez closed 11 months ago

Raidez commented 11 months ago

In my folder, I have a subfolder containing my project (pom and java), maven correctly detects the project, however there is no java file in the java explorer.

File explorer and java explorer

file explorer java explorer

Another working projetct

working
jdneo commented 11 months ago

Will the java project explorer show correct content if directly open that sub-folder in VS Code?

And btw, would you mind sharing your extension version please.

Raidez commented 11 months ago

It doesn't work when opening the subfolder. I should specify that I am connected to a WSL :

jdneo commented 11 months ago

Looks like due to some reason, the project is not imported as a Java project.

Does it work if you directly open it in windows instead of WSL?

If still not working, is it possible to share a sample project which can reproduce this issue?

Raidez commented 11 months ago

I found a strange point : demo.zip On this demo, all you have to do is comment on the maven-resources-plugin and click on "clean workspace" on the Java view and the java files magically disappear.

jdneo commented 11 months ago

Tried but working on MacOS. I'll find a Windows machine and try it in WSL later. image

jdneo commented 11 months ago

Still cannot repro using WSL

image

Could you share the server logs? You can get it by command Java: Open Java Language Server log file: https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#get-the-java-language-servers-workspace-logs

Raidez commented 11 months ago

My logs : NOK.log OK.log

jdneo commented 11 months ago

sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Looks like your WSL env has some issue to access your private Maven repo?

Raidez commented 11 months ago

This don't change the fact when I put maven-resources-plugin, I don't have problem. I work with IntelliJ too and without any more configuration, it works perfectly.

jdneo commented 11 months ago

AFAIK, IntelliJ has some extra work to auto configure the cert: https://www.jetbrains.com/help/idea/ssl-certificates.html

Hi @snjeza, do you know if there is any way to work around the issue sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target? Full log: https://github.com/microsoft/vscode-java-dependency/files/13216546/NOK.log

snjeza commented 11 months ago

@Raidez Could you run

$ mvn -version
$ mvn -U clean verify

and attach their output?

do you know if there is any way to work around the issue sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target? Full log: https://github.com/microsoft/vscode-java-dependency/files/13216546/NOK.log

You can try

$ echo -n | openssl s_client -connect my-enterprise-repo-maven:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/mycert.crt
$ cp <YOUR_JAVA_HOME>/lib/security/cacerts ~/cacerts.backup # optional
$ keytool -import -trustcacerts -keystore <YOUR_JAVA_HOME>/lib/security/cacerts -storepass changeit -noprompt -alias mycert -file /tmp/mycert.crt
Raidez commented 11 months ago
> mvn -version
Apache Maven 3.8.6 (Red Hat 3.8.6-4)
Maven home: /usr/share/maven
Java version: 17.0.9, vendor: Eclipse Adoptium, runtime: /usr/lib/jvm/temurin-17-jdk
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.123.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"

When it's OK/NOK (same result) :

> mvn -U clean verify
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
[INFO] Deleting /my-folder/demo/target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /my-folder/demo/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /my-folder/demo/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /my-folder/demo/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ demo ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ demo ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ demo ---
[INFO] Building jar: /my-folder/demo/target/demo-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.992 s
[INFO] Finished at: 2023-11-02T08:45:03+01:00
[INFO] ------------------------------------------------------------------------

Openssl don't works :

> openssl s_client -connect my-enterprise-repo-maven
40BC37C6F67F0000:error:10080002:BIO routines:BIO_lookup_ex:system lib:crypto/bio/bio_addr.c:738:Servname not supported for ai_socktype
connect:errno=0
snjeza commented 11 months ago

@Raidez could you show your maven repository url? could you try

$ ping my-enterprise-repo-maven
Raidez commented 11 months ago
> ping my-enterprise-repo-maven
ping: my-enterprise-repo-maven: Name or service not known
snjeza commented 11 months ago

@Raidez could you show your maven repository url?

Raidez commented 11 months ago

I can't show my maven url, but I discovered another thing. Forget the maven-resources-plugin, when I open my project with JAVA_HOME set to jdk17, it works perfectly. When I switching to jdk8, I got an error (same as NOK.log). The github said java 11 is required. My mistake.

jdneo commented 11 months ago

@Raidez Is your problem resolved?

Raidez commented 11 months ago

YEs

jdneo commented 11 months ago

Ok. Anyway, good to know the problem is fixed. And thank you @snjeza for the help! ❤