1
votes

I cannot analyze project where some classes are generated by Apache Axis WSDL2Java emitter. The project is build by Ant on Jenkins and analyzed by SonarQube Runner 2.4. How to solve this problem without ignoring the files during the analysis?

Build logs:

12:18:40 ERROR: Error during Sonar runner execution
12:18:40 org.sonar.runner.impl.RunnerException: Unable to execute Sonar
12:18:40    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
12:18:40    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
12:18:40    at java.security.AccessController.doPrivileged(Native Method)
12:18:40    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
12:18:40    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
12:18:40    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
12:18:40    at org.sonar.runner.api.Runner.execute(Runner.java:100)
12:18:40    at org.sonar.runner.Main.executeTask(Main.java:70)
12:18:40    at org.sonar.runner.Main.execute(Main.java:59)
12:18:40    at org.sonar.runner.Main.main(Main.java:53)
12:18:40 Caused by: java.lang.IllegalStateException: Can not execute Checkstyle
12:18:40    at org.sonar.plugins.checkstyle.CheckstyleExecutor.execute(CheckstyleExecutor.java:92)
12:18:40    at org.sonar.plugins.checkstyle.CheckstyleSensor.analyse(CheckstyleSensor.java:57)
12:18:40    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
12:18:40    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
12:18:40    at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
12:18:40    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:185)
12:18:40    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132)
12:18:40    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117)
12:18:40    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:243)
12:18:40    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:238)
12:18:40    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:228)
12:18:40    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132)
12:18:40    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117)
12:18:40    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:55)
12:18:40    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
12:18:40    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:132)
12:18:40    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:117)
12:18:40    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:    122)
12:18:40    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
12:18:40    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)
12:18:40    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
12:18:40    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:18:40    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
12:18:40    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12:18:40    at java.lang.reflect.Method.invoke(Method.java:497)
12:18:40    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
12:18:40    ... 9 more
12:18:40 Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing /var/lib/jenkins/workspace/nord_trunk_sonar/src/java/comarch/vibank/nord/factor/utilities/webservice/BankTockensSoapStub.java
12:18:40    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:282)
12:18:40    at org.sonar.plugins.checkstyle.CheckstyleExecutor.execute(CheckstyleExecutor.java:87)
12:18:40    ... 34 more
12:18:40 Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: MismatchedTokenException occurred during the analysis of file /var/lib/jenkins/workspace/nord_trunk_sonar/src/java/comarch/vibank/nord/factor/utilities/webservice/BankTockensSoapStub.java.
12:18:40    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:218)
12:18:40    at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:79)
12:18:40    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:266)
12:18:40    ... 35 more
12:18:40 Caused by: /var/lib/jenkins/workspace/nord_trunk_sonar/src/java/comarch/vibank/nord/factor/utilities/webservice/BankTockensSoapStub.java:30:9: expecting EOF, found 'oper'
12:18:40    at antlr.Parser.match(Parser.java:211)
12:18:40    at com.puppycrawl.tools.checkstyle.grammars.GeneratedJavaRecognizer.compilationUnit(GeneratedJavaRecognizer.java:210)
12:18:40    at com.puppycrawl.tools.checkstyle.TreeWalker.parse(TreeWalker.java:468)
12:18:40    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:200)
12:18:40    ... 37 more
12:18:40 ERROR: 
12:18:40 ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

BankTockensSoapStub.java content:

/**
 * BankTockensSoapStub.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis WSDL2Java emitter.
 */

package comarch.vibank.nord.factor.utilities.webservice;

public class BankTockensSoapStub extends org.apache.axis.client.Stub implements comarch.vibank.nord.factor.utilities.webservice.BankTockensSoap {
    private java.util.Vector cachedSerClasses = new java.util.Vector();
    private java.util.Vector cachedSerQNames = new java.util.Vector();
    private java.util.Vector cachedSerFactories = new java.util.Vector();
   private java.util.Vector cachedDeserFactories = new java.util.Vector();

    static org.apache.axis.description.OperationDesc [] _operations;

    static {
        _operations = new org.apache.axis.description.OperationDesc[1];
        org.apache.axis.description.OperationDesc oper;
        oper = new org.apache.axis.description.OperationDesc();
        oper.setName("returnTocken");
        oper.addParameter(new javax.xml.namespace.QName("http://www.comarch.com/", "ECODLogin"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
        oper.addParameter(new javax.xml.namespace.QName("http://www.comarch.com/", "viBankLogin"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
        oper.addParameter(new javax.xml.namespace.QName("http://www.comarch.com/", "viBankPass"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
        oper.setReturnType(new javax.xml.namespace.QName("http://www.comarch.com/", "RetRes"));
        oper.setReturnClass(comarch.vibank.nord.factor.utilities.webservice.RetRes.class);
        oper.setReturnQName(new javax.xml.namespace.QName("http://www.comarch.com/", "returnTockenResult"));
        oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
        oper.setUse(org.apache.axis.enum.Use.LITERAL);
        _operations[0] = oper;
    }
    ...

Line which causes an error:

        oper.setUse(org.apache.axis.enum.Use.LITERAL);

sonar-project.properties content:

sonar.projectKey=nord_trunk
sonar.projectName=Nord (trunk)
sonar.projectDescription=viBank for Nord
sonar.projectVersion=rev15358

sonar.sourceEncoding=Cp1250
sonar.language=java
sonar.java.source=1.4
sonar.java.target=1.4
sonar.sources=src/java,src/web_adk,src/web_corpo  
sonar.binaries=build/classes,web_corpo/WEB-INF/classes,web_adk/WEB-INF/classes
sonar.libraries=lib/*.jar,lib/xmlbeans/*.jar

sonar.scm.url=scm:svn:svn://hodor/nord/trunk
sonar.verbose=true

Environment:

  • SonarQube 5.3, java plugins:
    • Checkstyle 2.4
    • Findbugs 3.3
    • Java 3.9
    • PMD 2.5
  • Jenkins 1.644:
    • SonarQube Jenkins Plugin 2.3
    • SonarQube Runner 2.4
  • Oracle JDK 1.8.0 Update 66
1

1 Answers

0
votes

Checkstyle has problem with parsing Java 1.4 code. Type org.apache.axis.enum.Use is defined in package which uses reserved keyword enum.

After changing these two lines:

oper.setStyle(org.apache.axis.enum.Style.WRAPPED);
oper.setUse(org.apache.axis.enum.Use.LITERAL);

to:

oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
oper.setUse(org.apache.axis.constants.Use.LITERAL);

SonarQube analysis was successful. I didn't report an issue in Checkstyle backlog, because JDK 1.4 is already dead and I don't think that anybody will fix it.


A class used during tests:

public class CheckstyleAxisTest {

    private java.util.Vector cachedSerClasses = new java.util.Vector();
    private java.util.Vector cachedSerQNames = new java.util.Vector();
    private java.util.Vector cachedSerFactories = new java.util.Vector();
    private java.util.Vector cachedDeserFactories = new java.util.Vector();

    static org.apache.axis.description.OperationDesc[] _operations;

    static {
        _operations = new org.apache.axis.description.OperationDesc[1];
        org.apache.axis.description.OperationDesc oper;
        oper = new org.apache.axis.description.OperationDesc();
        oper.setName("returnTocken");
        oper.addParameter(new javax.xml.namespace.QName("http://www.comarch.com/", "ECODLogin"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
        oper.addParameter(new javax.xml.namespace.QName("http://www.comarch.com/", "viBankLogin"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
        oper.addParameter(new javax.xml.namespace.QName("http://www.comarch.com/", "viBankPass"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false);
        oper.setReturnType(new javax.xml.namespace.QName("http://www.comarch.com/", "RetRes"));
        oper.setReturnClass(java.lang.Object.class);
        oper.setReturnQName(new javax.xml.namespace.QName("http://www.comarch.com/", "returnTockenResult"));
        oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
        oper.setUse(org.apache.axis.constants.Use.LITERAL);
        _operations[0] = oper;
    }
}

Maven dependencies:

<dependency>
    <groupId>org.apache.axis</groupId>
    <artifactId>axis</artifactId>
    <version>1.4</version>
</dependency>

Test environment:

  • SonarQube 7.0, java plugins:
    • Checkstyle 4.8
    • Findbugs 3.6.0
    • Java 5.1.1
    • PMD 2.6
  • Jenkins 2.111:
    • SonarQube Jenkins Plugin 2.6.1
  • SonarQube Maven Scanner 3.4.0.905
  • Oracle JDK 1.8.0 Update 162