redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 438 forks source link

no definition found in maven project #2028

Open arjenzhou opened 3 years ago

arjenzhou commented 3 years ago

[provide a description of the issue]

Environment
Steps To Reproduce

giving a multi maven project:

├── projectA │   ├── pom.xml │   ├── A.java ├── projectB │   ├── pom.xml │   ├── B.java ├── pom.xml

in A.java, I cannot navigate into B.java, which is MPPQueueInfo.java below

image image

However, the project can build and run successfully. In another single maven project, nothing like this occurs.

arjenzhou commented 3 years ago
  ERR The request (id: 41, method: 'textDocument/hover') has been cancelled: Error: The request (id: 41, method: 'textDocument/hover') has been cancelled
    at /home/zhouyang/.vscode-server/extensions/redhat.java-0.80.0/dist/extension.js:2:855900
    at /home/zhouyang/.vscode-server/extensions/redhat.java-0.80.0/dist/extension.js:2:856194
    at Immediate.<anonymous> (/home/zhouyang/.vscode-server/extensions/redhat.java-0.80.0/dist/extension.js:2:856559)
    at processImmediate (internal/timers.js:461:21)
Access to XMLHttpRequest at 'https://bingsettingssearch.trafficmanager.net/api/Search' from origin 'vscode-file://vscode-app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
workbench.desktop.main.js:627  INFO Setting search error: XHR failed
workbench.desktop.main.js:76 POST https://bingsettingssearch.trafficmanager.net/api/Search net::ERR_FAILED
fbricon commented 3 years ago

@arjenzhou please attach a sample project reproducing this issue

arjenzhou commented 3 years ago

@arjenzhou please attach a sample project reproducing this issue

sry sir, I can't provide this project. I can provide Java language server log which seems help.

!ENTRY org.eclipse.jdt.ls.core 4 0 2021-07-19 17:14:36.172
!MESSAGE Failed to publish diagnostics for file:///***.java
!STACK 1
Java Model Exception: Java Model Status [*** [in ***] is not on its project's build path]
    at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:587)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:254)
    at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:528)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:248)
    at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:528)
    at org.eclipse.jdt.internal.core.CompilationUnit.openAncestors(CompilationUnit.java:1240)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:248)
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:600)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:330)
    at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:316)
    at org.eclipse.jdt.internal.core.Openable.getBuffer(Openable.java:296)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.publishDiagnostics(WorkspaceDiagnosticsHandler.java:274)
    at org.eclipse.jdt.ls.core.internal.handlers.WorkspaceDiagnosticsHandler.publishDiagnostics(WorkspaceDiagnosticsHandler.java:218)
    at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$2.run(JDTLanguageServer.java:303)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
!SUBENTRY 1 org.eclipse.jdt.core 4 1006 2021-07-19 17:14:36.172
!MESSAGE *** [in ***] is not on its project's build path

all files in two maven module throw the same exception

arjenzhou commented 3 years ago

the project is a multi maven project. two sub-modules appear like this, others do not

snjeza commented 3 years ago

@arjenzhou could you attach your .project, .classpath files?

arjenzhou commented 3 years ago

@snjeza ok, files here. https://gist.github.com/arjenzhou/58da6baa213be889201b4d28260610f3

arjenzhou commented 3 years ago

another message may help is that the project is using Java 8, settings.json here

{ 
    "files.autoSave": "afterDelay",
     "vim.handleKeys": {
        "<C-w>": false,
        "<C-c>": false,
        "<C-a>": false,
        "<C-q>": false,
    },
    "java.home": "/usr/lib/jvm/java-11-openjdk",
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-1.8",
            "path": "/usr/lib/jvm/java-8-openjdk",
            "default": true
        },
        {
            "name": "JavaSE-11",
            "path": "/usr/lib/jvm/java-11-openjdk",
        }
    ],
    "spring-boot.ls.java.home": "/usr/lib/jvm/java-11-openjdk",
    "maven.terminal.useJavaHome": true,
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "maven.executable.path": "/home/zhouyang/.sdkman/candidates/maven/current/bin/mvn",
    "redhat.telemetry.enabled": true,
    "workbench.colorTheme": "Github Light Theme - Gray",
    "workbench.iconTheme": "material-icon-theme",
    "editor.fontFamily": "'Fira Code', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
    "terminal.integrated.defaultProfile.linux": "bash",
    "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m -javaagent:\"/home/zhouyang/.vscode/extensions/gabrielbb.vscode-lombok-1.0.1/server/lombok.jar\"",
    "workbench.startupEditor": "none",
    "editor.fontSize": 15,
    "maven.excludedFolders": [
        "**/.*",
        "**/node_modules",
        "**/target",
        "**/bin",
        "**/archetype-resources"
    ],
    "java.semanticHighlighting.enabled": true,
    "maven.terminal.favorites": [
        {
            "alias": "cpt",
            "command": "clean package -DskipTests"
        },
        {
            "alias": "cit",
            "command": "clean install -DskipTests"
        },
    ],
    "maven.terminal.customEnv": [
        {
            "environmentVariable": "JAVA_HOME",
            "value": "/usr/lib/jvm/java-8-openjdk"
        }
    ],
    "java.requirements.JDK11Warning": false,
    "java.project.importOnFirstTimeStartup": "automatic"
}
snjeza commented 3 years ago

├── projectA │ ├── pom.xml │ ├── A.java ├── projectB │ ├── pom.xml │ ├── B.java ├── pom.xml

@arjenzhou could you move your java files to the /src/main/java directory?