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

NoClassDefError with the SonarScanner #2686

Open
shangchenlin opened this issue May 28, 2024 · 7 comments
Open

NoClassDefError with the SonarScanner #2686

shangchenlin opened this issue May 28, 2024 · 7 comments
Labels
Milestone

Comments

@shangchenlin
Copy link

Before you create a new issue

  • Is it really a cxx-plugin issue or a general SonarQube issue? To track SonarQube issues use the community from SonarSource please.
  • Please read the Wiki first, maybe you will find a solution there.
  • Please turn debug info on and reproduce your issue. The debug info in the log file could help to solve or locate the issue.
  • Please check if there is not already a bug report for your issue.

Describe the bug
When I run the command line which the SonarQube gave me, it kept jump the NoClassDefError

Screenshots
cmd_UXwMMFP2JE
cmd_qwtaAaOmGF

Desktop (please complete the following information):

  • OS:Windows10
  • SonarQube version: 9.9.5 LTS
  • cxx plugin version:2.1.1
  • sonar-scanner version: 5.0.1.3006
  • jdk version:17
@guwirth
Copy link
Collaborator

guwirth commented May 28, 2024

Hi @shangchenlin,

the NoClassDefError comes from CxxUnitTestResultsAggregator in


l.add(CxxUnitTestResultsAggregator.class);

That‘s one of the first steps during setup of the plugin, long before any analysis is executed. Wondering how that could be because CI tests are running?
https://github.com/SonarOpenCommunity/sonar-cxx/actions/runs/9267875389

  • Are you running it on a cloud platform or on a local PC?
  • Which Java distribution are you using?

Regards,

@guwirth
Copy link
Collaborator

guwirth commented May 28, 2024

Duplicate #2634, #2475

#2475 has been solved with:

The issue has been solved. The resolution was to clear the /var/lib/jenkins/.sonar tmp files and the /var/lib/jenkins/.sonar/cache as well as ensure the /var/lib/jenkins/.sonar/cache/_tmp folder had the correct ownership:group

@guwirth guwirth added this to the 2.1.1 milestone May 28, 2024
@shangchenlin
Copy link
Author

shangchenlin commented May 29, 2024

I am running on local PC with Oracle Java 17, I didn't run any testing, I just want to analyze the .xml which cpp check gave, I have another question is that is this plugin really need cpp check?
Also, this is my current SonarQube showed
image
image
Uploading image.png…

@guwirth
Copy link
Collaborator

guwirth commented May 29, 2024

is this plugin really need cpp check?

SonarQube C++ Community plugin (cxx plugin): This plugin adds C++ support to SonarQube with the focus on integration of existing C++ tools. …the main purpose of the cxx plugin is to forward reports from 3rd party tools to SonarQube. The plugin is not doing any static code analysis by its own. If you want that you have to use the SQ developer edition with the cpp plugin.

@qathy
Copy link

qathy commented Jun 27, 2024

Duplicate #2634, #2475

#2475 has been solved with:

The issue has been solved. The resolution was to clear the /var/lib/jenkins/.sonar tmp files and the /var/lib/jenkins/.sonar/cache as well as ensure the /var/lib/jenkins/.sonar/cache/_tmp folder had the correct ownership:group

We don't use Jenkins to run our CI jobs, but GitLab CI which launches jobs on docker containers (hence, clean) using the official image sonarsource/sonar-scanner-cli:latest and despite this hopefully clean environment, we do experience the same java.lang.ClassNotFoundException: org.sonar.cxx.sensors.tests.dotnet.CxxUnitTestResultsAggregator issue.

NB: aggregator is used to collect compilation warnings from both Linux and Windows platforms, ccpcheck analysis, gcov results as well as valgrind output.

@guwirth do you have any hint, like using a better docker image, for instance?
Or do we have to inject the pluggin, or an updated version, in the container?

@Aga303
Copy link

Aga303 commented Jul 3, 2024

We don't use Jenkins to run our CI jobs, but GitLab CI which launches jobs on docker containers (hence, clean) using the official image sonarsource/sonar-scanner-cli:latest and despite this hopefully clean environment, we do experience the same java.lang.ClassNotFoundException: org.sonar.cxx.sensors.tests.dotnet.CxxUnitTestResultsAggregator issue.

We have the same setup and the same problem. And ours does not even have C++ code. Removing the sonar-caches did not help. In production we run sonar-scanner-cli:5 and that's working without problems.

@guwirth
Copy link
Collaborator

guwirth commented Jul 3, 2024

The NoClassDefFoundError is a runtime error in Java that occurs if the Java Virtual Machine (JVM) or a ClassLoader instance attempts to load the definition of a class but cannot find it at runtime. The class definition exists at compile-time but is not available at runtime.

What I still don’t understand is, that everything is working fine in our test environments. Why is only sometimes the dependency to the class CxxUnitTestResultsAggregator not available at runtime? Someone an idea?

Found this: https://rollbar.com/blog/java-no-class-def-found-error/

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