SonarQube - strange OutOfMemoryError: PermGen space - java

I know that there are similar questions out here, but none seems to provide a solution, so I hope that my setting is somewhat different, so that there may be a solution at least for this specific problem:
For some reasons we are stuck to SonarQube 4.5.6 at the moment, trying to analyse a huge Java project (12.000 files with about 1.000.000 lines of code). The rule set consists of about 700 rules spread over the java-plugin (latest version 3.11), findbugs (latest version 3.3), checkstyle (need to use an older version here - 2.2, cause of some rules not available in later versions), and pmd (latest version 2.5).
With Sonar Runner 2.4 the parts of java-plugin, findbugs (with a timeout set to about 20 minutes), checkstyle run through, but within pmd I keep getting an OutOfMemoryError: PermGen space
17:56:31.276 INFO - Sensor PmdSensor...
17:56:31.279 INFO - Execute PMD 5.4.0...
17:56:31.313 INFO - Java version: 1.5
17:56:31.360 INFO - PMD configuration: C:\src\.\.sonar\pmd.xml
17:57:23.679 INFO - Execute PMD 5.4.0 done: 52400 ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 57:33.538s
Final Memory: 47M/3908M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at net.sourceforge.pmd.lang.java.typeresolution.PMDASMClassLoader.loadClass(PMDASMClassLoader.java:65)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.populateType(ClassTypeResolver.java:655)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:179)
at net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration.jjtAccept(ASTImportDeclaration.java:62)
at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:55)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:9)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:136)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:170)
at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.jjtAccept(ASTCompilationUnit.java:42)
at net.sourceforge.pmd.lang.java.typeresolution.TypeResolutionFacade.initializeWith(TypeResolutionFacade.java:17)
at net.sourceforge.pmd.lang.java.AbstractJavaHandler$5.start(AbstractJavaHandler.java:88)
at net.sourceforge.pmd.SourceCodeProcessor.usesTypeResolution(SourceCodeProcessor.java:127)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:142)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:76)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:43)
at org.sonar.plugins.pmd.PmdTemplate.process(PmdTemplate.java:82)
at org.sonar.plugins.pmd.PmdExecutor.executeRules(PmdExecutor.java:120)
at org.sonar.plugins.pmd.PmdExecutor.executePmd(PmdExecutor.java:90)
at org.sonar.plugins.pmd.PmdExecutor.execute(PmdExecutor.java:75)
at org.sonar.plugins.pmd.PmdSensor.analyse(PmdSensor.java:67)
The stack trace says I'm still in pmd, but the pmd seems to have already been through analysis (line Execute PMD 5.4.0 done: ...), and there shouldn't be another plug-in running thereafter. Nevertheless, I wonder where I should increase the PermGen space ... I already have
wrapper.java.additional.2=-XX:MaxPermSize=8g
wrapper.java.maxmemory=8g
in wrapper.conf and also tried to add
set JAVA_OPTS="-XX:PermSize=256m -XX:MaxPermSize=4096m"
in sonar-runner.bat. In addition there's
sonar.web.javaOpts=-server -Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
in sonar.properties. First, I don't understand which setting is the one responsible for the OutOfMemoryError - the one in wrapper.conf? the one in sonar-runner.bat? or sonar.properties?
What can I do when PermSize of 8g isn't helping?? The default size is 128m or something, so it's already a factor of 64!?
Any idea, how to analyse this project with SonarQube? The problem occurs as well with the built-in database as with a MySQL, so I don't think that that has any influence.
Any help appreciated. Thanks ... if you need any more info about configuration or have an idea to get some more infos out of some logs, please let me know.

You need to allocate the extra memory not on the server side, but on the analysis side to the process that runs the analysis. Since you appear to be analyzing using the SonarQube Scanner, I'll direct you to the Troubleshooting section of those docs, where it tells you how to adjust the memory settings for the process by exporting a SONAR_RUNNER_OPTS env var.

Related

How to debug Java SE 6 using Eclipse 2022-12?

I cannot debug Java SE 6 using Eclipse 2022-12, It throws the following exception:
java.lang.UnsupportedClassVersionError: org/eclipse/jdt/launching/internal/javaagent/Premain : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"
However, I can run this project (Java SE 6) without any problem. I can also run and debug another Java SE 7 normally.
It's same as the problem posted here: https://www.eclipse.org/forums/index.php/mv/msg/1112218/1856754/
It's maybe happen since this change: https://github.com/eclipse-jdt/eclipse.jdt.debug/issues/61
So. is there a way to debug Java SE 6 using eclipse 2022-12, thank you.
TL;DR
Downgrade your Eclipse (we are using 2022-03)
Double check Java version after that
Long story
A colleague had this problem today and after some tinkering we've got it to work. His Eclipse was also stopping at a ghost breakpoint. He had never ever worked on that project and we had cleaned up everything, but even then, it would stop at a breakpoint and break with the mentioned error.
After reading the links in this question, now I understand why this worked, but the second item was very unexpected:
I was on 2022-03 where it was working, so we downgraded his Eclipse to 2022-03 as well. As you pointed out, it seems they have made a change that created this bug during debug mode for Java 1.6.
After that, we double checked Java version everywhere and we found out that the Java 1.6 that was showing up on Eclipse was actually a Java 11 (it was written like "JavaSE-1.6 (jdk 11)"), so we forced it to use from a new Java 1.6 location. I assume Eclipse mixed up something, because I think it runs on Java 11.
After that, debug was working again.

Eclipse on Windows: Exception in thread "main" java.lang.UnsupportedClassVersionError: MainMethod : Unsupported major.minor version 52.0

I have been trying to fix this problem for several hours now, and I am totally at my wits end.
My old computer crashed, but luckily I was able to recover most of my files. I installed eclipse on my desktop, and attempted to import a few projects into eclipse. Every one of them had problems, and not a single one will run. I am running Windows 7 on a homebuild PC- I am 99% sure this is not a hardware problem, I don't think you need specs.
First, every time I import I have followed this thread because it is the first of my problems: every time I import a project, eclipse will not recognize anything from java and I apparently need to manually tell it what to use (which is annoying, and if anyone has a fix for this it would be great to know how to stop it).
But the big problem comes after I fix that. Whenever I try to run the project, no matter which project it is I get the error I copied in the description:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MainMethod : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
I have tried just about everything, and am getting pretty close to just breaking the whole thing. I have followed all of the following guides: this one, this one and this one. All of them say to do the same thing: change the project preferences and check the compiler settings. The settings should match.
I am running JDK7 and JRE7. JRE8/JDK8 is not installed anywhere on my desktop- I am not sure why eclipse seems to think it is. My question is this: how do I fix this problem? Do I need to do a clean install and follow a specific set of steps to stop this from happening? Do I need to put JDK8 on my computer? Do I need ro re-import the projects into the workspace in a specific way? Am I just stuck?
If you have followed the steps of configuring JDK, the project might be referring to previously generated classes. You may try Project on menu > Clean, select all projects and then try to run the application.
Moreover, go to Project Properties, Java Build Path, Libraries and confirm that you are referring to the correct Java Runtime version.
Your project was created with a version of Java JDK, but your eclipse has a older version of JDK.
Verify if the version of your project's JDK is the same of the eclipse's JDK.

Using jasperstarter to compile and run iReport "java.lang.UnsupportedClassVersionError"

Basically what I want to do is create a PDF from a iReport jrxml or jasper file.
The idea is to use this for reports over the net and the best solution I managed to find was to use a program like jasperstarter and then run the report with a connection to MSSQL database.
To get the connection going I had to download the latest net.sourceforge.jtds.jdbc.Driver.
The report works fine using iReport 5.1 but when I do follow the instructions from jasperstarter I get an "java.lang.UnsupportedClassVersionError" response.
jasperstarter command
jasperstarter pr -t generic -f pdf -i test_report.jasper -o test -u username -p password --db-driver net.sourceforge.jtds.jdbc.Driver --db-url jdbc:jtds:sqlserver://LOCAL-PC/Demo_DB
output
Exception in thread "main" java.lang.UnsupportedClassVersionError: net/sourcefor
ge/jtds/jdbc/Driver : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at de.cenote.jasperstarter.Db.getConnection(Db.java:69)
at de.cenote.jasperstarter.Report.fill(Report.java:220)
at de.cenote.jasperstarter.App.processReport(App.java:222)
at de.cenote.jasperstarter.App.main(App.java:107)
Please advice.
Basically, you are trying to run code that was compiled on / for Java 7 on an older JVM.
That doesn't work.
Either:
run your application on a Java 7 JVM (or later1); i.e. upgrade your Java version,
find a build of the JDTS driver that is suitable for your execution platform, or
find the source for the JDTS driver and build it for your platform.
For more detailed information on this exception and its causes, read:
http://stackoverflow.com/questions/10382929.
1 - Note that even Java 7 is end-of-life now. If you are still running that version of Java you should upgrade.
Make sure you have same JRE and JDK.
If not sure un-install download the latest JDK and try again.
Note that the JDK does install the JRE automatically.

Error launching Luke(Java App) from WinXP

I downloaded luke-1.0.1.jar (Luke 1.0.1 binary without any dependencies) from http://code.google.com/p/luke/downloads/list.
And I have WinXP, with latest Java 6 downloaded from Oracle/Sun web site.
I run the command line: "java -jar luke-1.0.1.jar" and try to launch Luke, but I got following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.Analyzer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.getopt.luke.Luke. Program will exit.
Any clue, what shall I do? I totally have no knowledge of Java.
Thanks
Hardy
So Java complains that it cant find a dependency. Which is little surprise since you downloaded a binary without dependencies.
Download the binary with all the dependencies (try the "featured" one) and you should be good.
Use luke-all.jar instead,
http://code.google.com/p/luke/downloads/detail?name=lukeall-1.0.1.jar&can=2&q=
Luke is a tool for examining lucene indices. You need to combine it with Lucene. You can either download Lucene and add appropriare JAR files to the classpath, or download a fatter Luke binary that includes Lucene.

BIRT report created via eclipse throwing error on execution

I've a particular birt project which I've created using the eclipse ide. I am trying to understand how to deploy the report without having to use alternatives which would cost something.
So ultimately I am left with the birt report engine api. I've downloaded the report engine runtime package from the birt-exchange web site. I've found a particular script (ms-dos batch file - genReport.bat) which can generate reports from the rptdesign file.
There are particular some basic sample reports in this package which demonstrate how we can generate a report. The script is able to execute against these sample reports. However when I try to execute the script against a reports I've created via the birt-eclipse ide I get the following error. (I've pasted it right out of the command prompt):
Oct 13, 2009 2:14:46 PM org.eclipse.birt.report.engine.api.impl.ReportEngineHelp
er openReportDesign
SEVERE: invalid design file file:/C:/Documents%20and%20Settings/arun.jayapal/wor
kspace/atsusersReport/atsUsers.rptdesign
Oct 13, 2009 2:14:46 PM org.eclipse.birt.report.engine.api.ReportRunner runAndRe
nderReport
SEVERE: The design file file:/C:/Documents%20and%20Settings/arun.jayapal/workspa
ce/atsusersReport/atsUsers.rptdesign has error and can not be run.
org.eclipse.birt.report.engine.api.EngineException: The design file file:/C:/Doc
uments%20and%20Settings/arun.jayapal/workspace/atsusersReport/atsUsers.rptdesign
has error and can not be run.
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReport
Design(ReportEngineHelper.java:258)
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReport
Design(ReportEngineHelper.java:193)
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReport
Design(ReportEngineHelper.java:127)
at org.eclipse.birt.report.engine.api.impl.ReportEngine.openReportDesign
(ReportEngine.java:349)
at org.eclipse.birt.report.engine.api.ReportRunner.runAndRenderReport(Re
portRunner.java:192)
at org.eclipse.birt.report.engine.api.ReportRunner.execute(ReportRunner.
java:165)
at org.eclipse.birt.report.engine.api.ReportRunner.main(ReportRunner.jav
a:120)
Caused by: Error.DesignFileException.INVALID_XML - 1 errors found!
1.) ( line = 0, tag = null) org.eclipse.birt.report.model.parser.DesignParserE
xception (code = Error.DesignParserException.UNSUPPORTED_VERSION, message : The
report file of version "3.2.20" is invalid for it is greater than the latest sup
ported one.)
at org.eclipse.birt.report.model.parser.ModuleReader.readModule(ModuleRe
ader.java:116)
at org.eclipse.birt.report.model.parser.DesignReader.read(DesignReader.j
ava:88)
at org.eclipse.birt.report.model.core.DesignSession.openDesign(DesignSes
sion.java:321)
at org.eclipse.birt.report.model.api.SessionHandle.openDesign(SessionHan
dle.java:294)
at org.eclipse.birt.report.engine.parser.ReportParser.getDesignHandle(Re
portParser.java:158)
at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.openReport
Design(ReportEngineHelper.java:253)
... 6 more
Caused by: org.eclipse.birt.report.model.parser.DesignParserException: The repor
t file of version "3.2.20" is invalid for it is greater than the latest supporte
d one.
at org.eclipse.birt.report.model.parser.ModuleState.parseAttrs(ModuleSta
te.java:112)
at org.eclipse.birt.report.model.parser.ModuleParserHandler.startElement
(ModuleParserHandler.java:229)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startEle
ment(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElem
ent(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$Conten
tDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$Prolog
Driver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(U
nknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp
l.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
nknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
urce)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un
known Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p
arse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.birt.report.model.parser.ModuleReader.readModule(ModuleRe
ader.java:94)
How to resolve this?
I've recently done a BIRT deployment and find that it can be kind of finicky. I had the error you're describing when I tried to load and preview reports in eclipse that were generated by someone running a later version of the BIRT eclipse tools.
It looks like the samples you have are out of sync with the environment you're trying to run it on. Try upgrading the environment (since you're in eclipse, that would be your installed birt reporting plugins).

Categories

Resources