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

Missing Gradle project configuration file: .settings/org.eclipse.buildship.core.prefs #2528

Closed
ai-chen2050 opened this issue Jun 24, 2022 · 11 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#2289
Labels

Comments

@ai-chen2050
Copy link

ai-chen2050 commented Jun 24, 2022

[provide a description of the issue]
image

Environment

env:

  • Visual Studio Code version: latest
  • Java extension version: 1.7
  • apple m1 pro
  • latest java pack
  • use Oracle JDK 1.8 to run the program, and use OpenJDK 17 to jdt, as the java server.
Steps To Reproduce

1、use Oracle JDK 1.8 to run the program, and use OpenJDK 17 to jdt, as the java server.
2、compile https://github.com/tronprotocol/java-tron

[Please attach a sample project reproducing the error]
Please attach logs

Current Result

Error, Access restriction: The type 'OperatingSystemMXBean' is not API . Can't debug

Expected Result

No error

Additional Informations

java compile server some info as follow:

!ENTRY org.eclipse.jdt.ls.core 4 0 2022-06-24 00:40:59.039
!MESSAGE Error occured while building workspace. Details:
message: Access restriction: The method 'OperatingSystemMXBean.getProcessCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 70
message: Access restriction: The method 'OperatingSystemMXBean.getSystemCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 78
message: Access restriction: The method 'OperatingSystemMXBean.getTotalPhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 94
message: Access restriction: The method 'OperatingSystemMXBean.getFreePhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 102
message: Access restriction: The method 'OperatingSystemMXBean.getTotalSwapSpaceSize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 109
message: Access restriction: The method 'OperatingSystemMXBean.getFreeSwapSpaceSize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 116
message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 5
message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 44
message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 47
message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/common/src/main/java/org/tron/common/prometheus/OperatingSystemExports.java; line: 51
message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 3
message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 41
message: Access restriction: The type 'OperatingSystemMXBean' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 41
message: Access restriction: The method 'OperatingSystemMXBean.getTotalPhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 75
message: Access restriction: The method 'OperatingSystemMXBean.getFreePhysicalMemorySize()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 76
message: Access restriction: The method 'OperatingSystemMXBean.getSystemCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 77
message: Access restriction: The method 'OperatingSystemMXBean.getProcessCpuLoad()' is not API (restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar'); code: 16777523; resource: /Users/blake.chen/work/code/opensource/java-tron/framework/src/main/java/org/tron/core/services/NodeInfoService.java; line: 84

!ENTRY org.eclipse.jdt.ls.core 1 0 2022-06-24 00:41:01.712
!MESSAGE >> workspace/executeCommand vscode.java.resolveBuildFiles

@ai-chen2050
Copy link
Author

ai-chen2050 commented Jun 24, 2022

Help! It's been bothering me two days. @fbricon @Eskibear @gbraad @LightGuard @otaviof

@gbraad
Copy link
Member

gbraad commented Jun 24, 2022

Please, do not just at-reply users to get attention. I have no idea what this is about.

Especially as you just filed the issue and expect people to jump to your help. We also have a job and a life.

@ai-chen2050
Copy link
Author

ai-chen2050 commented Jun 24, 2022

Please, do not just at-reply users to get attention. I have no idea what this is about.

Especially as you just filed the issue and expect people to jump to your help. We also have a job and a life.

Oh, sorry, It's github's Recommended. My fault. Have a good day.

@gbraad
Copy link
Member

gbraad commented Jun 24, 2022

Recommended? This must be very wrong as it also includes people who aren't members of the organization.

@LightGuard
Copy link
Member

Really can't help. Using the com.sun.* packages have never been recommended. They're internal classes subject to change anytime.

@ai-chen2050
Copy link
Author

Recommended? This must be very wrong as it also includes people who aren't members of the organization.

Apologize again. Happy weekend! 😄

@ai-chen2050
Copy link
Author

Really can't help. Using the com.sun.* packages have never been recommended. They're internal classes subject to change anytime.

Thx! okay, I got it. An open-source project that I study recently dependency the com.sun.* packages, I will remind the project side.
Have a nice weekend.

@CsCherrYY
Copy link
Contributor

@ai-chen2050 I can reproduce this. IIUC The problems "xxx is not API" will not stop you from debugging, but you just encountered another error about missing prefs file, which might block you. Here is a workaround:

  1. Set java.import.generatesMetadataFilesAtProjectRoot to true (better in workspace scope)
  2. Press F1 to open the command palette, type Java: Clean Java Language Server Workspace, run this command
  3. After reloading and importing, your project might remain only "xxx is not API" errors, and you might be able to debug, just choose Proceed if there is any tips about the error.

@jdneo jdneo changed the title Access restriction: The type 'OperatingSystemMXBean' is not API Missing Gradle project configuration file: .settings/org.eclipse.buildship.core.prefs Jun 27, 2022
@jdneo jdneo added the bug label Jun 27, 2022
@CsCherrYY
Copy link
Contributor

I can also reproduce it via:

  1. clone https://github.com/spring-projects/spring-petclinic
  2. open it in eclipse, by default, eclipse will import it as a Maven project and generate metadata files
  3. open this project in VS Code, there is a notification shows to choose build tool, choose "Gradle"
  4. The same error appears.

@lupino3
Copy link

lupino3 commented Sep 4, 2022

Thanks for the workaround @CsCherrYY, I had the same issue on GitHub Codespaces and your workaround worked perfectly.

@wolfg1969
Copy link

@ai-chen2050 I fixed "xxx is not API" errors in a gradle project like this:

build.gradle.kts

plugins {
    eclipse
   // other plugins ...
}

eclipse {
    classpath {
        file {
            whenMerged {
                val classpath = this as org.gradle.plugins.ide.eclipse.model.Classpath
                val jre = classpath.entries.find { 
                    when (it) {
                        is org.gradle.plugins.ide.eclipse.model.Container -> it.path.contains("org.eclipse.jdt.launching.JRE_CONTAINER")
                        else -> false
                    }
                } as org.gradle.plugins.ide.eclipse.model.Container
                jre.accessRules.add(org.gradle.plugins.ide.eclipse.model.AccessRule("accessible", "com/sun/net/**"))
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
8 participants