How to fix SecurityException from class org.eclipse.jdt.core.dom.ASTUtils?

I am trying to Consume Sonar API , During file scanning getting below issue , I have tried sonar community but still struggling to fix…Please anyone help me to resolve this issue

Caused by: java.lang.SecurityException: class “org.eclipse.jdt.core.dom.ASTUtils”'s signer information does not match signer information of other classes in the same package
** at java.base/java.lang.ClassLoader.checkCerts(ClassLoader.java:1150)**
** at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:905)**
** at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1014)**
** at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)**
** at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)**
** at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)**
** at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)**
** at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)**
** at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)**
** at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)**
** at org.sonar.java.model.JParser.convert(JParser.java:197)**
** at org.sonar.java.model.JParser.parse(JParser.java:165)**
** at org.sonar.java.model.JParserConfig$FileByFile.parse(JParserConfig.java:268)**
** … 5 more**
```

Hey there.

What version of SonarQube / the API are you using? In what contest are you receiving an error – while building your project? While performing a scan?

1 Like

Hello Colin,
Thanks for your response. I fixed this issue “Sonar Version mismatch”,

Hello Colin & Team,
I am currently working to automate sonar issues using Rules https://github.com/SonarSource/sonar-java. In my local, I am not able to do this job,
For example,
I am taking StringToStringCheckTest class, I would like to work without below code

String string = "hello".toString(); // Noncompliant [[sc=21;ec=28;quickfixes=qf1]]
	    // fix@qf1 {{Remove "toString()"}}
	    // edit@qf1 [[sc=28;ec=39]] {{}}

While execute I got this error

Exception in thread "main" java.lang.AssertionError: Unexpected at [9]
	at org.sonar.java.checks.verifier.internal.InternalCheckVerifier.assertMultipleIssues(InternalCheckVerifier.java:412)

Please give me any good solution to automate fix sonar issue using Rule or without Rule,

Hey there.

To make sure I understand correctly, you get that error when you remove this block of code?

1 Like

Hello Colin,
Yes, you are correct, When i remove a block of code, I receive the error.
but I would like to use without this commented codes because of i am using webapi https://***********.com/api/issues/search?severities=MAJOR&componentKeys=branch=test&statuses=OPEN&asc=false based on the API results, I should apply the rules

First of all, when I removed those three lines, the code still compiles successfully (with tests run).

Secondly, I think I understand more what you’re speaking about – while yes, java:s125 is being raised on this code, these comments are actually a part of how the Sonar API runs the tests (it indicates which code is noncompliant and what columns are a part of the issue. Removing the comments will likely cause the tests to get confused and fail.

As a result, when we (SoanarSource) scan the code, we ignore these issues on these directories to prevent the issues from being raised at all.

1 Like

Okay, I understood your points. I am trying to do an automatic fix for some sonar issues. Do you have any suggestions?
Automatic fix like walkmod?