Error during SonarScanner execution after executing SonarScanner.MSBuild.exe end command - java

Sonarqube Version -7.9.5
SonarQube Scanner - sonar-scanner-msbuild-5.0.4.24009-net46
Source code contains - C#, angular.js, html5, javascript.
Hi,
I executed the following commands and after executing the 3rd command I am getting execution failure error.
The command I executed in the CMD prompt are browsing to the path where solution is present are,
SonarScanner.MSBuild.exe begin /k:"Demo" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="TokenID_ABC"
MsBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login="TokenID_ABC"
ERROR: Error during SonarScanner execution
org.sonar.java.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property
I found one similar kind of issue reported where it is said that due to .java file present in the code the issue occurs, in our code as well .java files are present, not sure the use of them. How can I exclude those .java files while SonarQube analysis is performed and in which file do I need to add exclusion code?
Also, if there is some another solution to resolve this issue, then please let me know as I have very limited knowledge of Sonar.
Link of similar issue -
https://community.sonarsource.com/t/error-while-running-sonar-scanner-please-provide-compiled-classes-of-your-project-with-sonar-java-binaries-property/30027/2

You can exclude arbitrary files by going to your project settings in SonarQube -> Analysis Scope -> Source File Exclusions. Use regex to match your java files, i.e. *.java.

Related

Javadoc warning - bad source file: file does not contain class com.example.MyClass

I have a file called MyFile.java and it contains multiple classes(none of them is public). Note that the file does not contain MyFile class. Apparently Javadoc is not happy about this and it generates a warning saying file does not contain class com.example.MyClass. A few solutions I looked into:
Move classes into their own files. This looks like the proper way of fixing the warnings, but the new files won't obliviously have the source control history, so I am trying to avoid it.
Create empty MyFile class. This is ugly.
Hide Javadoc warnings, preferably per file. There is a high chance that this is not possible.
A few questions that I have:
Why does Javadoc complain? I couldn't find any documentation, please point me to one. I think it is perfectly fine not to have a class with the same name as the file.
Any other suggestions I can look into?
Is it possible to hide warnings somehow? additionalparam="-Xdoclint:none" does not work.
Thank you all in advance
When building with maven from the command line, I encountered this error from maven-javadoc-plugin.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:jar (default) on project code-mapping-database: MavenReportException: Error while generating Javadoc:
... error: cannot access DataSourceWrapper
Eclipse IDE reported a similar error.
This occurred after I had copied DataSourceWrapper.java to another (dependent) project and commented out all lines of DataSourceWrapper.java in the original project. After deleting the commented out version, the error went away. The effectively empty DataSourceWrapper.java file must have caused maven-javadoc-plugin to stop looking for class DataSourceWrapper.

baffling logback bug TimeBasedArchiveRemover$ArhiveRemoverRunnable

Logback 1.1.7
This was during a "production" run: stack trace from Exception (actually NoClassDefFoundError is an Error):
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/rolling/helper/TimeBasedArchiveRemover$ArhiveRemoverRunnable
at ch.qos.logback.core.rolling.helper.TimeBasedArchiveRemover.cleanAsynchronously(TimeBasedArchiveRemover.java:231)
at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.rollover(TimeBasedRollingPolicy.java:178)
at ch.qos.logback.core.rolling.RollingFileAppender.attemptRollover(RollingFileAppender.java:204)
at ch.qos.logback.core.rolling.RollingFileAppender.rollover(RollingFileAppender.java:183)
at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:224)
at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:100)
So I looked at the source: that class ArhiveRemoverRunnable does indeed exist in the .java file where it should have been instantiated on l. 231 (with that mis-spelling)...
Then I unpacked the executable jar (logback-core-1.1.7.jar): again, the file TimeBasedArchiveRemover$ArhiveRemoverRunnable.class exists in the package, as does file TimeBasedArchiveRemover.class.
This error is not going to happen that often: it is obviously when the "rolling" logger decides it's time to clean up the directory.
Anyone got any idea why this might happen? Troublingly I find no evidence of anyone else experiencing this...!
Potential workaround (pending):
I thought the answer to this might be to extract the source files for this .jar, edit the offending class, compile and repackage as an executable jar, and then use instead of the downloaded jar. In order to do this I started a new Gradle project in Eclipse, imported the entire source package, etc. The thing compiles (builds) OK in Eclipse-with-Gradle, with no complaints of the "NoClassDef" type...
But I'm having difficulties actually producing this executable jar. It'd be a nice thing to be able to accomplish: ability to tweak and test a downloaded dependency in some way (if really necessary).
Current not so satisfactory workaround:
In fact I have no need for a "time-based" archive remover. I'm quite happy just having archives removed on the basis of the size of all the files in the logging directory. This answer appears to solve this. However, logback is quite a beast: I'm not entirely sure: is "archive removal" the same thing as "rollover"?
If the Error occurs again, of course, I shall have to make a special utility method to log every LOGGER.xxx command within a try...catch.

Stanford OpenIE example code compile error

http://nlp.stanford.edu/software/openie.shtml generates compile time error :
SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation cannot be resolved to a type
I am running java-8 under eclipse 2016. corenlp-full-2015-12-01.zip, openie.jar, openie-models.jar are in included in my eclipse project.
Error generated by line of:
System.out.println(sentence.get(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class).toString(SemanticGraph.OutputFormat.LIST));
thanks
If I were to guess, this sounds like a classpath issue. What happens if you remove either openie.jar or the corenlp distribution? In theory, openie.jar should contain everything you need to run the Open IE system.
I have the same error.
What does this package edu.stanford.nlp.naturalli; in the first line of the code snippet mean?
I do not have much Java knowledge, I just created a Java project somewhere and included the same files as WH Sweet did.
I just found that within the corenlp project subfolder naturalli there is a OpenIEDemo.java already. Maybe the explanation for this would solve the initial problem..

log4j how to avoid "unknown source" message

Am using my java application with log4j as logging mechanism
For most of the debug statements of the 3rd party jars am using, am getting filename with line numbers like
com.abc.xyz.GG(doFilter:67)
but for my source code, am getting the following
com.xyz.abc.class (unknown source problem)
Its tough for me to debug my source code since there is no line number info.
Can Someone please help me how do I enable this....
Thanks in advance....
Did you compile your code with the "-g:none" option of javac?
If so, the compiler doesn't generate any debugging information and Log4j cannot fetch them.
You need to pass -g option when calling the javac command.
From the Oracle documentation:
-g
Generate all debugging information, including local variables. By default, only line number and source file information is generated.
If you using ant to build your project you need to set the javac task's debug attribute to on, like this:
<javac debug="on">...</javac>

Populating Team Build summary with errors / warning from an ant build

I am using TFS 2008 and team build to compile some Java code using ant and the Microsoft Team Foundation Server 2010 Build Extensions. My experience is with the Microsoft stack and ant is a bit of an unknown for me, we have a contractor who knows all about the Java / ant world but he's never used TFS before.
I've created a TFSbuild.proj which calls an ant build.xml file. The build runs and compiles the code, the output is copied to the drop location, so all of that is good. However when I inspect the build log I can see lots of warnings from the Java compiler, but the build summary says 0 errors, 0 warnings.
Our coding standards dictate that all compiler and static code anlysis warnings should be addressed and the build summary is a great way to let developers know that they need to look at the code. Is there any way of getting ant to return the errors / warnings back to team build so that it can populate the build summary with the warnings? Below are some examples of the warnings I can see in the log.
[buildObjects] E:\Build\Sources\Project\custom\WEB-INF\config\Configuration\Audit Configuration.xml: warning: You are overring an object imported by init.xml with the same 'Audit Configuration' but with a different ID '#ID#Configuration:AuditConfiguration'.
[buildObjects] E:\Build\Sources\Project\custom\WEB-INF\config\AdminGroup\Manager Operations.xml: warning: It is a recommended best practice that the object 'Manage Operations' specify an ID '#ID#AdminGroup:Manage Operations'.
[buildObjects] E:\Build\Project\custom\WEB-INF\config\AdminRole\AdminRole-operations.xml: warning: ObjectRef to object 'IS Admin' cannot be resolved in the current project.
[buildObjects] E:\Build\Project\custom\WEB-INF\config\Configuration\SubProcess-addAccessManager.xml:153: warning: Unresolved reference to variable 'user'. Variable is assumed to be a task input variable.
The Build Extensions power tool should be parsing out errors and warnings and putting them into your build log already I think. Can you drop me a line (martinwo#microsoft.com) with your ant log output and I'll try and take a look? I'll edit this answer again once we've figured it out.

Categories

Resources