java.lang.ClassCastException in SonarQube analysis after Java Plugin upgrade to version 3.4 -
after upgrading sonarqube java plugin version 3.4 analysis fails followin error:
[error] failed execute goal org.codehaus.mojo:sonar-maven-plugin:2.4:sonar (default-cli) on project machweb: sonarqube unable analyze file : 'd:\jenkins\workspace\dvlp mw1.0 coverage und codeanalyse\ejbs\src\mach\logistik\entities\mmarktplatz.java': org.sonar.java.model.expression.parenthesizedtreeimpl cannot cast org.sonar.plugins.java.api.tree.identifiertree -> [help 1] org.apache.maven.lifecycle.lifecycleexecutionexception: failed execute goal org.codehaus.mojo:sonar-maven-plugin:2.4:sonar (default-cli) on project machweb: sonarqube unable analyze file : 'd:\jenkins\workspace\dvlp mw1.0 coverage und codeanalyse\ejbs\src\mach\logistik\entities\mmarktplatz.java' @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:216) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:153) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:145) @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:116) @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:80) @ org.apache.maven.lifecycle.internal.builder.singlethreaded.singlethreadedbuilder.build(singlethreadedbuilder.java:51) @ org.apache.maven.lifecycle.internal.lifecyclestarter.execute(lifecyclestarter.java:120) @ org.apache.maven.defaultmaven.doexecute(defaultmaven.java:347) @ org.apache.maven.defaultmaven.execute(defaultmaven.java:154) @ org.apache.maven.cli.mavencli.execute(mavencli.java:582) @ org.apache.maven.cli.mavencli.domain(mavencli.java:214) @ org.apache.maven.cli.mavencli.main(mavencli.java:158) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.codehaus.plexus.classworlds.launcher.launcher.launchenhanced(launcher.java:289) @ org.codehaus.plexus.classworlds.launcher.launcher.launch(launcher.java:229) @ org.codehaus.plexus.classworlds.launcher.launcher.mainwithexitcode(launcher.java:415) @ org.codehaus.plexus.classworlds.launcher.launcher.main(launcher.java:356) caused by: org.apache.maven.plugin.mojoexecutionexception: sonarqube unable analyze file : 'd:\jenkins\workspace\dvlp mw1.0 coverage und codeanalyse\ejbs\src\mach\logistik\entities\mmarktplatz.java' @ org.codehaus.mojo.sonar.bootstrap.exceptionhandling.handle(exceptionhandling.java:42) @ org.codehaus.mojo.sonar.bootstrap.runnerbootstraper.execute(runnerbootstraper.java:135) @ org.codehaus.mojo.sonar.sonarmojo.execute(sonarmojo.java:136) @ org.apache.maven.plugin.defaultbuildpluginmanager.executemojo(defaultbuildpluginmanager.java:132) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:208) ... 19 more caused by: org.sonar.squidbridge.api.analysisexception: sonarqube unable analyze file : 'd:\jenkins\workspace\dvlp mw1.0 coverage und codeanalyse\ejbs\src\mach\logistik\entities\mmarktplatz.java' @ org.sonar.java.ast.javaastscanner.simplescan(javaastscanner.java:102) @ org.sonar.java.ast.javaastscanner.scan(javaastscanner.java:75) @ org.sonar.java.javasquid.scansources(javasquid.java:131) @ org.sonar.java.javasquid.scan(javasquid.java:124) @ org.sonar.plugins.java.javasquidsensor.analyse(javasquidsensor.java:86) @ org.sonar.batch.phases.sensorsexecutor.executesensor(sensorsexecutor.java:79) @ org.sonar.batch.phases.sensorsexecutor.execute(sensorsexecutor.java:70) @ org.sonar.batch.phases.phaseexecutor.execute(phaseexecutor.java:119) @ org.sonar.batch.scan.modulescancontainer.doafterstart(modulescancontainer.java:194) @ org.sonar.api.platform.componentcontainer.startcomponents(componentcontainer.java:93) @ org.sonar.api.platform.componentcontainer.execute(componentcontainer.java:78) @ org.sonar.batch.scan.projectscancontainer.scan(projectscancontainer.java:233) @ org.sonar.batch.scan.projectscancontainer.scanrecursively(projectscancontainer.java:228) @ org.sonar.batch.scan.projectscancontainer.scanrecursively(projectscancontainer.java:226) @ org.sonar.batch.scan.projectscancontainer.doafterstart(projectscancontainer.java:221) @ org.sonar.api.platform.componentcontainer.startcomponents(componentcontainer.java:93) @ org.sonar.api.platform.componentcontainer.execute(componentcontainer.java:78) @ org.sonar.batch.scan.scantask.scan(scantask.java:64) @ org.sonar.batch.scan.scantask.execute(scantask.java:51) @ org.sonar.batch.bootstrap.taskcontainer.doafterstart(taskcontainer.java:125) @ org.sonar.api.platform.componentcontainer.startcomponents(componentcontainer.java:93) @ org.sonar.api.platform.componentcontainer.execute(componentcontainer.java:78) @ org.sonar.batch.bootstrap.bootstrapcontainer.executetask(bootstrapcontainer.java:173) @ org.sonar.batch.bootstrapper.batch.executetask(batch.java:95) @ org.sonar.batch.bootstrapper.batch.execute(batch.java:67) @ org.sonar.runner.batch.isolatedlauncher.execute(isolatedlauncher.java:48) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ org.sonar.runner.impl.batchlauncher$1.delegateexecution(batchlauncher.java:87) @ org.sonar.runner.impl.batchlauncher$1.run(batchlauncher.java:75) @ java.security.accesscontroller.doprivileged(native method) @ org.sonar.runner.impl.batchlauncher.doexecute(batchlauncher.java:69) @ org.sonar.runner.impl.batchlauncher.execute(batchlauncher.java:50) @ org.sonar.runner.api.embeddedrunner.doexecute(embeddedrunner.java:102) @ org.sonar.runner.api.runner.execute(runner.java:100) @ org.codehaus.mojo.sonar.bootstrap.runnerbootstraper.execute(runnerbootstraper.java:131) ... 22 more caused by: java.lang.classcastexception: org.sonar.java.model.expression.parenthesizedtreeimpl cannot cast org.sonar.plugins.java.api.tree.identifiertree @ org.sonar.java.checks.stringconcatenationinloopcheck.getidentifiertree(stringconcatenationinloopcheck.java:98) @ org.sonar.java.checks.stringconcatenationinloopcheck.getidentifiertree(stringconcatenationinloopcheck.java:92) @ org.sonar.java.checks.stringconcatenationinloopcheck.isnotlooplocalvar(stringconcatenationinloopcheck.java:80) @ org.sonar.java.checks.stringconcatenationinloopcheck.visitassignmentexpression(stringconcatenationinloopcheck.java:73) @ org.sonar.java.model.expression.assignmentexpressiontreeimpl.accept(assignmentexpressiontreeimpl.java:73) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitexpressionstatement(basetreevisitor.java:101) @ org.sonar.java.model.statement.expressionstatementtreeimpl.accept(expressionstatementtreeimpl.java:66) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:37) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitblock(basetreevisitor.java:85) @ org.sonar.java.model.statement.blocktreeimpl.accept(blocktreeimpl.java:77) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitifstatement(basetreevisitor.java:107) @ org.sonar.java.model.statement.ifstatementtreeimpl.accept(ifstatementtreeimpl.java:124) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:37) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitblock(basetreevisitor.java:85) @ org.sonar.java.model.statement.blocktreeimpl.accept(blocktreeimpl.java:77) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitforstatement(basetreevisitor.java:151) @ org.sonar.java.checks.stringconcatenationinloopcheck.visitforstatement(stringconcatenationinloopcheck.java:155) @ org.sonar.java.model.statement.forstatementtreeimpl.accept(forstatementtreeimpl.java:118) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:37) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitblock(basetreevisitor.java:85) @ org.sonar.java.model.statement.blocktreeimpl.accept(blocktreeimpl.java:77) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitifstatement(basetreevisitor.java:107) @ org.sonar.java.model.statement.ifstatementtreeimpl.accept(ifstatementtreeimpl.java:124) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:37) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitblock(basetreevisitor.java:85) @ org.sonar.java.model.statement.blocktreeimpl.accept(blocktreeimpl.java:77) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitifstatement(basetreevisitor.java:107) @ org.sonar.java.model.statement.ifstatementtreeimpl.accept(ifstatementtreeimpl.java:124) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:37) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitblock(basetreevisitor.java:85) @ org.sonar.java.model.statement.blocktreeimpl.accept(blocktreeimpl.java:77) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitmethod(basetreevisitor.java:80) @ org.sonar.java.model.declaration.methodtreeimpl.accept(methodtreeimpl.java:215) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:37) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitclass(basetreevisitor.java:69) @ org.sonar.java.model.declaration.classtreeimpl.accept(classtreeimpl.java:199) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:37) @ org.sonar.plugins.java.api.tree.basetreevisitor.visitcompilationunit(basetreevisitor.java:55) @ org.sonar.java.model.javatree$compilationunittreeimpl.accept(javatree.java:136) @ org.sonar.plugins.java.api.tree.basetreevisitor.scan(basetreevisitor.java:43) @ org.sonar.java.checks.stringconcatenationinloopcheck.scanfile(stringconcatenationinloopcheck.java:67) @ org.sonar.java.model.visitorsbridge.visitfile(visitorsbridge.java:123) @ org.sonar.java.ast.javaastscanner.simplescan(javaastscanner.java:94) ... 59 more [error] [error] re-run maven using -x switch enable full debug logging. [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/mojoexecutionexception
searching stackoverflow led me this similar problem
the solution (upgrading java plugin version 3.4) not work since upgraded 3.4. furthermore, rule causing error different, squid:s1643 (strings should not concatenated using '+' in loop):
caused by: java.lang.classcastexception: org.sonar.java.model.expression.parenthesizedtreeimpl cannot cast org.sonar.plugins.java.api.tree.identifiertree @ org.sonar.java.checks.stringconcatenationinloopcheck.getidentifiertree(stringconcatenationinloopcheck.java:98)
deactivating rule workaround, still use rule. sonarqube version lts (4.5.4).
thanks feedback. unfortunately can't reproduce issue on side based on stack trace. identify , provide simple reproducer of issue? (you should have string concatenation including parentheses somewhere in file causing exception)
Comments
Post a Comment