luntbuild + maven + findbugs = OutOfMemoryException - continuous-integration

I've been trying to get Luntbuild to generate and publish a project site for our project including a Findbugs report. All other reports (Cobertura, Surefire, JavaDoc, Dashboard) work fine, but Findbugs bails out with an OutOfMemoryException. Excluding findbugs from report generation fixes the build --- although obviously without a Findbugs report.
The funny thing is that I first encountered this problem locally and solved it by setting MAVEN_OPTS=-Xmx512m. This does not seem to be enough in Luntbuild, however: setting that exact same option as an environment variable of my builder doesn't make a difference.
I've found a couple of posts on the 'net stating you should also add -XX:MaxPermSize=512m to MAVEN_OPTS and/or pass -Dmaven.findbugs.jvmargs=-Xmx512m to mvn.bat. None of these (or their combination) seem to help though so any hints would be greatly appreciated!
Cheers,
Johannes
Relevant information:
Luntbuild is 1.5.6, Maven is 2.1.0, findbugs-maven-plugin is 2.0.1.
This is the Findbugs section of the relevant pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.0.1</version>
</plugin>
This is the head of my build log:
User "luntbuild" started the build
Perform checkout operation for VCS setting:
Vcs name: Subversion
Repository url base: http://some.repository.com/repo/
Repository layout: multiple
Directory for trunk: trunk
Directory for branches: branches
Directory for tags: tags
Username: xxxx
Password:xxxx
Web interface: ViewVC
URL to web interface: http://some.repository.com/repo/
Quiet period:
modules:
Source path: somepath, Branch: , Label: , Destination path: somewhere
Source path: somepath, Branch: somewhere1.0.x, Label: , Destination path: somewhere-1.0.x
Source path: somepath, Branch: somewhere1.1.x, Label: , Destination path: somewhere-1.1.x
Update url: http://some.repository.com/repo//trunk
Duration of the checkout operation: 0 minutes
Perform build with builder setting:
Builder name: default
Builder type: Maven2 builder
Command to run Maven2: "C:\maven\apache-maven-2.1.0\bin\mvn.bat" -e -f somewhere\pom.xml -P site -Dmaven.test.skip=false -DbuildDate="Tue Nov 24 11:13:24 CET 2009" -DbuildVersion="site-core138"
-Dsvn.username=xxxx -Dsvn.password=xxxx -DstagingSiteURL=file:///C:/luntbuild/core-reports
-Dmaven.findbugs.jvmargs=-Xmx512m
Directory to run Maven2 in:
Goals to build: site:stage site:stage-deploy
Build properties: buildVersion="site-core138"
artifactsDir="C:\\Program Files\\Luntbuild\\publish\\somewhere\\site-core\\site-core138\\artifacts"
buildDate="Tue Nov 24 11:13:24 CET 2009"
junitHtmlReportDir=""
Environment variables: MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=512m"
Build success condition: result==0 and builderLogContainsLine("INFO","BUILD SUCCESSFUL")
Execute command: Executing 'C:\maven\apache-maven-2.1.0\bin\mvn.bat' with arguments:
'-e'
'-f'
'somewhere\pom.xml'
'-P'
'site'
'-Dmaven.test.skip=false'
'-DbuildDate=Tue Nov 24 11:13:24 CET 2009'
'-DbuildVersion=site-core138'
'-Dsvn.username=xxxxxx'
'-Dsvn.password=xxxxxx'
'-DstagingSiteURL=file:///C:/luntbuild/reports'
'-Dmaven.findbugs.jvmargs=-Xmx512m'
'-DbuildVersion=site-core138'
'-DartifactsDir=C:\\Program Files\\Luntbuild\\publish\\somewhere\\site-core\\site-core138\\artifacts'
'-DbuildDate=Tue Nov 24 11:13:24 CET 2009'
'-X'
'site:stage'
'site:stage-deploy'
Tail of my build log:
Analyzed: C:\luntbuild\somewhere-work\somewhere\...\SomeClass.class
...
Analyzed: C:\luntbuild\somewhere-work\somewhere\...\target\classes
Aux: C:\luntbuild\somewhere-work\somewhere\...\target\classes
Aux: c:\maven\local-repo\...\somejar-1.1.1.1-SNAPSHOT.jar
Aux: c:\maven\local-repo\commons-lang\commons-lang\2.3\commons-lang-2.3.jar
....
Aux: c:\maven\local-repo\org\openoffice\ridl\3.1.0\ridl-3.1.0.jar
Aux: c:\maven\local-repo\org\openoffice\unoil\3.1.0\unoil-3.1.0.jar
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Java heap space
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.(HashMap.java:209)
at edu.umd.cs.findbugs.ba.type.TypeAnalysis$CachedExceptionSet.(TypeAnalysis.java:114)
at edu.umd.cs.findbugs.ba.type.TypeAnalysis.getCachedExceptionSet(TypeAnalysis.java:688)
at edu.umd.cs.findbugs.ba.type.TypeAnalysis.computeThrownExceptionTypes(TypeAnalysis.java:439)
at edu.umd.cs.findbugs.ba.type.TypeAnalysis.transfer(TypeAnalysis.java:411)
at edu.umd.cs.findbugs.ba.type.TypeAnalysis.transfer(TypeAnalysis.java:89)
at edu.umd.cs.findbugs.ba.Dataflow.execute(Dataflow.java:356)
at edu.umd.cs.findbugs.classfile.engine.bcel.TypeDataflowFactory.analyze(TypeDataflowFactory.java:82)
at edu.umd.cs.findbugs.classfile.engine.bcel.TypeDataflowFactory.analyze(TypeDataflowFactory.java:44)
at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.analyzeMethod(AnalysisCache.java:331)
at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getMethodAnalysis(AnalysisCache.java:281)
at edu.umd.cs.findbugs.classfile.engine.bcel.CFGFactory.analyze(CFGFactory.java:173)
at edu.umd.cs.findbugs.classfile.engine.bcel.CFGFactory.analyze(CFGFactory.java:64)
at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.analyzeMethod(AnalysisCache.java:331)
at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getMethodAnalysis(AnalysisCache.java:281)
at edu.umd.cs.findbugs.ba.ClassContext.getMethodAnalysis(ClassContext.java:937)
at edu.umd.cs.findbugs.ba.ClassContext.getMethodAnalysisNoDataflowAnalysisException(ClassContext.java:921)
at edu.umd.cs.findbugs.ba.ClassContext.getCFG(ClassContext.java:326)
at edu.umd.cs.findbugs.detect.BuildUnconditionalParamDerefDatabase.analyzeMethod(BuildUnconditionalParamDerefDatabase.java:103)
at edu.umd.cs.findbugs.detect.BuildUnconditionalParamDerefDatabase.considerMethod(BuildUnconditionalParamDerefDatabase.java:93)
at edu.umd.cs.findbugs.detect.BuildUnconditionalParamDerefDatabase.visitClassContext(BuildUnconditionalParamDerefDatabase.java:79)
at edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:68)
at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:971)
at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:222)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:230)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:912)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:756)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17 minutes 16 seconds
[INFO] Finished at: Tue Nov 24 11:31:23 CET 2009
[INFO] Final Memory: 70M/127M
[INFO] ------------------------------------------------------------------------
Maven2 builder failed: build success condition not met!
Note that apparently maven only uses 70MB... but that probably doesn't mean anything since the Findbugs plugin forks its own process.

I don't have any experience with either of: Luntbuild or maven, but this might help you:
if the error message is "OutOfMemoryError: Java heap space", then Xmx setting is the one for you. -XX:MaxPermSize=512m option deals with PermGen space, which is a different one.
If, as you mention, FindBugs starts its own process, then setting MAVEN_OPTS doesn't seem to be relevant. I would suggest trying to find how to set the Xmx for FindBugs JVM. Probably others will come with details on how to do it.
EDIT:
Documentation for Maven FindBugs Plugin seems to cover the topic of setting heap size. The default value is 512M and you can change it using maxHeap. The only problem is that it seems to be possible only since version 2.2.

Related

How to configure a Jenkins Pipeline for SonarQube scan

I am trying to configure a jenkins pipeline for my project, but there is something missing here, if anyone could direct on what I am doing wrong:
Below is the pipeline script:
node {
stage('SonarQube analysis') {
// requires SonarQube Scanner 2.8+
def scannerHome = tool 'sonarScanner';
withSonarQubeEnv('SonarQube 6.2') {
bat "${scannerHome}/bin/sonar-runner.bat"
}
}
}
Below is the Jenkins Sonar Plugin related configurations:
Under Manage Jenkins > Configure System:
Under Manage Jenkins > Global Tool Configuration
Below is the error that I get:
D:\jenkins\workspace\Test_Pipeline>D:\sonar-runner-2.4/bin/sonar-runner.bat
D:\sonar-runner-2.4
SonarQube Runner 2.4
Java 1.8.0_92 Oracle Corporation (64-bit)
Windows Server 2008 R2 6.1 amd64
INFO: Runner configuration file: D:\sonar-runner-2.4\conf\sonar-runner.properties
INFO: Project configuration file: NONE
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: D:\jenkins\workspace\Test_Pipeline\.\.sonar
INFO: SonarQube Server 6.2
19:48:53.627 INFO - Load global repositories
19:48:53.920 INFO - Load global repositories (done) | time=298ms
19:48:53.951 WARN - Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
19:48:53.951 WARN - Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
19:48:53.951 WARN - Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
19:48:53.951 INFO - User cache: C:\Users\Administrator\.sonar\cache
19:48:54.378 INFO - Load plugins index
19:48:54.378 INFO - Load plugins index (done) | time=0ms
19:48:55.235 INFO - Process project properties
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 3.404s
Final Memory: 5M/120M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
[Pipeline] }
[Pipeline] // wrap
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
The problem seems that Jenkins does not know where my sonar-project.properties is placed. It is under D:\myprj and has contents as below:
# required metadata
sonar.projectKey=my_prj:my_prj
sonar.projectName=my_prj
sonar.projectVersion=1.00
sonar.sources=my_prj/src
sonar.language=java
Pls suggest how I can make Jenkins pipeline aware of where the sonar-project.properties file is placed
I needed to add the workspace to my script. Here is the script below:
stage('SonarQube analysis') {
ws('D:\\my_prj') {
// requires SonarQube Scanner 2.8+
def scannerHome = tool 'sonarScanner';
withSonarQubeEnv('SonarQube 6.2') {
bat "${scannerHome}/bin/sonar-scanner.bat"
}
}
}
I see you were using Sonar-runner 2.4. I think by running 2.8 version you will have better results. This is my JenkinsFile configuration, by using Declarative Pipeline syntax. I was having the same issue, but I solved it by renaming my sonar-project.properties file, the previous name was "sonar.properties". I hope this may help others.
stage('Sonarqube analysis') {
steps {
script {
scannerHome = tool 'SonarScanner';
}
withSonarQubeEnv('SonarQube') {
bat "${scannerHome}/bin/sonar-scanner.bat"
}
}
}

sonarqube-gradle-plugin: Wrong base directory derived for sub-projects two levels deep

I have a multi-project with the following structure:
:very:bestappever
:bestappever-distrib
The SonarQubePlugin gives
:sonarqube
09:35:05.139 INFO - Load global repositories
09:35:05.252 INFO - Load global repositories (done) | time=114ms
09:35:05.254 INFO - Server id: 20160428045618
09:35:05.256 INFO - User cache: C:\Users\tk09\.sonar\cache
09:35:05.265 INFO - Install plugins
09:35:05.401 INFO - Install JDBC driver
09:35:05.414 INFO - Create JDBC datasource for jdbc:mysql://10.48.213.38:3306/sonar
09:35:06.456 INFO - Initializing Hibernate
:sonarqube FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sonarqube'.
> The base directory of the module ':very:bestappever' does not exist: C:\Workarea\verybestappever\very\:very:bestappever
You may note, that the full path of project ':very:bestappever' is inserted at the wrong place.
This may be related to https://jira.sonarsource.com/browse/SONARGRADL-12 from which I've adopted the bestappever example by moving the :bestappever project to :very:bestappever. You can find this example at https://github.com/ThiporKong/sonarqube-gradle-issue.
Am I missing something? Are there any configuration options that can be used to work with deeply nested gradle multi-projects? I've tried the proposals from Sonarqube how to configure gradle sub-projects correctly? but to no avail.
Thanks and regards,
Thipor
Problem also reported on SonarQube user group. A ticket was created (https://jira.sonarsource.com/browse/SONARGRADL-14) and a bugfix release 2.0.1 was deployed on Gradle plugin portal.

Setting encoding for SCM Activity plugin for sonar-maven-plugin?

I use SonarQube 4.2 with SCM Activity [scmactivity] 1.7 with sonar-maven-plugin 4.2.
Upon executing mvn sonar:sonar I'm seeing the following:
[INFO] --- sonar-maven-plugin:4.2:sonar (default-cli) # ... ---
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: ...\target\sonar
INFO: SonarQube Server 4.2
...
[INFO] [15:43:51.829] Source encoding: UTF-8, default locale: en_US
...
[INFO] [15:43:59.169] Sensor ScmActivitySensor...
[INFO] [15:43:59.169] Trying to guess scm provider from project layout...
[INFO] [15:43:59.170] Found SCM type: svn
[INFO] [15:43:59.170] Retrieve SCM blame information with encoding windows-1250...
[INFO] [15:43:59.343] Retrieve SCM blame information with encoding windows-1250 done: 173 ms
[INFO] [15:43:59.345] Sensor ScmActivitySensor done: 176 ms
How can the encoding be set up to another one, say UTF-8?
Try adding these to the properties section of the POM:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Currently you can't. This is the line responsible for printing the encoding:
TimeProfiler profiler = new TimeProfiler().start("Retrieve SCM blame information with encoding " + Charset.defaultCharset());
However, this is somewhat misleading, because author names are always normalized and stripped of all non ascii characters:
authors.add(lineNumber, normalizeString(line.getAuthor()));
...
private String normalizeString(String inputString) {
String lowerCasedString = inputString.toLowerCase();
String stringWithoutAccents = removeAccents(lowerCasedString);
return removeNonAsciiCharacters(stringWithoutAccents);
So actually, the encoding has no impact.

using Typesafe Activator on Windows

I tried to run the hello-slick template from inside Typesafe Activator.
When it recompiled it produced:
Refreshing list of source files to watch for changes...
[info] Loading global plugins from C:\Users\Edward G Prentice\.sbt\plugins\project
[info] Loading global plugins from C:\Users\Edward G Prentice\.sbt\plugins
[info] Loading project definition from C:\Users\Edward G Prentice\hello-slick\project
[info] Set current project to hello-slick (in build file:/C:/Users/Edward%20G%20Prentice/hello-slick/)
[error] Expected '"'
[error] apply -cp "C:/Users/Edward
[error] ^
Failed to reload source file list: sbt process never got in touch, so unable to handle request WatchTransitiveSourcesRequest(true)
so clearly it is not expecting spaces in that portion of the classpath. I understand what's failing but not how to fix it.
...and what is the best channel to resolve problems with Typesafe Activator?

Error Compiling Netty latest (Master) version

I would like to test some of the latest features locate in netty Master branch at github.
(git://github.com/netty/netty.git)
I'm doing the following steps:
Open new empty directory on my local machine
Type git init
Type git pull git://github.com/netty/netty.git
Compile pom.xml using maven as follow: mvn clean package
I now get the following compliation error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.855s
[INFO] Finished at: Sun Jan 08 12:14:21 IST 2012
[INFO] Final Memory: 16M/176M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project netty: Compilation failure: Compilation
failure:
[ERROR] \tradair\tools\netty\src\main\java\io\netty\util\internal\LegacyLinkedTransferQueue.java:[655,61] type parameters of <E>E cannot be determined; no uniqu
e maximal instance exists for type variable E with upper bounds E,java.lang.Object
[ERROR] \tradair\tools\netty\src\main\java\io\netty\util\internal\LegacyLinkedTransferQueue.java:[739,53] type parameters of <E>E cannot be determined; no uniqu
e maximal instance exists for type variable E with upper bounds E,java.lang.Object
[ERROR] \tradair\tools\netty\src\main\java\io\netty\util\internal\LegacyLinkedTransferQueue.java:[827,57] type parameters of <E>E cannot be determined; no uniqu
e maximal instance exists for type variable E with upper bounds E,java.lang.Object
[ERROR] \tradair\tools\netty\src\main\java\io\netty\util\internal\LegacyLinkedTransferQueue.java:[880,65] type parameters of <E>E cannot be determined; no uniqu
e maximal instance exists for type variable E with upper bounds E,java.lang.Object
Can you please advise what I'm doing wrong.
LinkedTransferQueue back-porting was done recently in master, so you better try with latest version of JDK 6, (>= 1.6.0_25, a compiler bug?)
That's a java bug (I hit it before also). Upgrade to latest jdk and it will work. I don't recall what exactly version of java was giving the problems

Resources