SonarQube is unable to analyze file

1,115 views
Skip to first unread message

sharmaa...@gmail.com

unread,
Sep 7, 2015, 4:47:33 AM9/7/15
to SonarQube
Hi Guys,

I am using SonarQube server 5.1.2 and sonar-runner-2.4 to analyze my project. For one file I am facing one problem - java.lang.IndexOutOfBoundsException: index (0) must be less than size (0). Related stack trace is as follows

10:07:28.434 DEBUG - Completing symbol : Object
10:07:28.434 DEBUG - Completing symbol : XmlRegistry
10:07:28.434 DEBUG - Completing symbol : Retention
10:07:28.434 DEBUG - Completing symbol : Documented
10:07:28.434 DEBUG - Completing symbol : RetentionPolicy
10:07:28.435 DEBUG - Completing symbol : Enum
10:07:28.435 DEBUG - Completing symbol : Comparable
10:07:28.435 DEBUG - Completing symbol : Class
10:07:28.435 DEBUG - Completing symbol : Constructor
10:07:28.435 DEBUG - Completing symbol : Map
10:07:28.435 DEBUG - Completing symbol : Set
10:07:28.435 DEBUG - Completing symbol : Collection
10:07:28.435 DEBUG - Completing symbol : Iterable
10:07:28.435 DEBUG - Completing symbol : Iterator
10:07:28.435 DEBUG - Completing symbol : Entry
10:07:28.435 DEBUG - Completing symbol : TypeVariable
10:07:28.436 DEBUG - Completing symbol : CallerSensitive
10:07:28.436 DEBUG - Completing symbol : Target
10:07:28.436 DEBUG - Completing symbol : ElementType
10:07:28.436 DEBUG - Completing symbol : SoftReference
10:07:28.436 DEBUG - Completing symbol : Reference
10:07:28.436 DEBUG - Completing symbol : ReferenceQueue
10:07:28.437 DEBUG - Completing symbol : Character
10:07:28.438 DEBUG - Completing symbol : Deprecated
10:07:28.438 DEBUG - Completing symbol : Serializable
10:07:28.438 DEBUG - Completing symbol : Float
10:07:28.438 DEBUG - Completing symbol : Number
10:07:28.498 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@42d21e87[id=2810,key=TestProject,qualifier=TRK], with key batch-TestProject
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1:34.593s
Final Memory: 33M/1277M
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: org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : '/var/lib/jenkins/jobs/TestProject/workspace/src/com/coe/abh/intranet/fooclasses/ObjectFactory.java'
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:102)
at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:75)
at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:131)
at org.sonar.java.JavaSquid.scan(JavaSquid.java:124)
at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:86)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51)
at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
Caused by: java.lang.IndexOutOfBoundsException: index (0) must be less than size (0)
at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:301)
at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:280)
at com.google.common.collect.EmptyImmutableList.get(EmptyImmutableList.java:106)
at org.sonar.java.ast.parser.ListTreeImpl.get(ListTreeImpl.java:170)
at org.sonar.java.checks.ImmediateReverseBoxingCheck.visitNode(ImmediateReverseBoxingCheck.java:95)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:89)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:115)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:91)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:115)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:91)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:115)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:91)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:115)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:91)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:115)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:91)
at org.sonar.java.ast.visitors.SubscriptionVisitor.scanTree(SubscriptionVisitor.java:72)
at org.sonar.java.ast.visitors.SubscriptionVisitor.scanFile(SubscriptionVisitor.java:65)
at org.sonar.java.checks.SubscriptionBaseVisitor.scanFile(SubscriptionBaseVisitor.java:33)
at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:123)
at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:94)
... 38 more


Nicolas Peru

unread,
Sep 7, 2015, 5:02:08 AM9/7/15
to sharmaa...@gmail.com, SonarQube
Hi, 

This sounds like an issue in a java check. Could you share the version of the java plugin you are using as well as the source code of the ObjectFactory.java class ?
Sounds like a primitive wrapper is instantiated with no argument which should not happen. 

Cheers, 


Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/94d8949f-00f8-459a-9357-071cfc8e2035%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sharmaa...@gmail.com

unread,
Sep 7, 2015, 5:16:10 AM9/7/15
to SonarQube, sharmaa...@gmail.com
java plugin version - 3.4


Source code

package com.coe.abh.intranet.fooclasses; 

import javax.xml.bind.annotation.XmlRegistry;


@XmlRegistry
public class ObjectFactory {


    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.w3._1999.xsl.format
     * 
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link PageNumberCitation }
     * 
     */
    public PageNumberCitation createPageNumberCitation() {
        return new PageNumberCitation();
    }

    /**
     * Create an instance of {@link Root }
     * 
     */
    public Root createRoot() {
        return new Root();
    }

    /**
     * Create an instance of {@link LayoutMasterSet }
     * 
     */
    public LayoutMasterSet createLayoutMasterSet() {
        return new LayoutMasterSet();
    }

    /**
     * Create an instance of {@link SimplePageMaster }
     * 
     */
    public SimplePageMaster createSimplePageMaster() {
        return new SimplePageMaster();
    }

    /**
     * Create an instance of {@link RegionBody }
     * 
     */
    public RegionBody createRegionBody() {
        return new RegionBody();
    }

    /**
     * Create an instance of {@link RegionBefore }
     * 
     */
    public RegionBefore createRegionBefore() {
        return new RegionBefore();
    }

    /**
     * Create an instance of {@link RegionAfter }
     * 
     */
    public RegionAfter createRegionAfter() {
        return new RegionAfter();
    }

    /**
     * Create an instance of {@link RegionStart }
     * 
     */
    public RegionStart createRegionStart() {
        return new RegionStart();
    }

    /**
     * Create an instance of {@link RegionEnd }
     * 
     */
    public RegionEnd createRegionEnd() {
        return new RegionEnd();
    }

    /**
     * Create an instance of {@link PageSequenceMaster }
     * 
     */
    public PageSequenceMaster createPageSequenceMaster() {
        return new PageSequenceMaster();
    }

    /**
     * Create an instance of {@link SinglePageMasterReference }
     * 
     */
    public SinglePageMasterReference createSinglePageMasterReference() {
        return new SinglePageMasterReference();
    }

    /**
     * Create an instance of {@link RepeatablePageMasterReference }
     * 
     */
    public RepeatablePageMasterReference createRepeatablePageMasterReference() {
        return new RepeatablePageMasterReference();
    }

    /**
     * Create an instance of {@link RepeatablePageMasterAlternatives }
     * 
     */
    public RepeatablePageMasterAlternatives createRepeatablePageMasterAlternatives() {
        return new RepeatablePageMasterAlternatives();
    }

    /**
     * Create an instance of {@link ConditionalPageMasterReference }
     * 
     */
    public ConditionalPageMasterReference createConditionalPageMasterReference() {
        return new ConditionalPageMasterReference();
    }

    /**
     * Create an instance of {@link Declarations }
     * 
     */
    public Declarations createDeclarations() {
        return new Declarations();
    }

    /**
     * Create an instance of {@link ColorProfile }
     * 
     */
    public ColorProfile createColorProfile() {
        return new ColorProfile();
    }

    /**
     * Create an instance of {@link PageSequence }
     * 
     */
    public PageSequence createPageSequence() {
        return new PageSequence();
    }

    /**
     * Create an instance of {@link Title }
     * 
     */
    public Title createTitle() {
        return new Title();
    }

    /**
     * Create an instance of {@link Character }
     * 
     */
    public Character createCharacter() {
        return new Character();
    }

    /**
     * Create an instance of {@link ExternalGraphic }
     * 
     */
    public ExternalGraphic createExternalGraphic() {
        return new ExternalGraphic();
    }

    /**
     * Create an instance of {@link InstreamForeignObject }
     * 
     */
    public InstreamForeignObject createInstreamForeignObject() {
        return new InstreamForeignObject();
    }

    /**
     * Create an instance of {@link Inline }
     * 
     */
    public Inline createInline() {
        return new Inline();
    }

    /**
     * Create an instance of {@link Marker }
     * 
     */
    public Marker createMarker() {
        return new Marker();
    }

    /**
     * Create an instance of {@link Leader }
     * 
     */
    public Leader createLeader() {
        return new Leader();
    }

    /**
     * Create an instance of {@link PageNumber }
     * 
     */
    public PageNumber createPageNumber() {
        return new PageNumber();
    }

    /**
     * Create an instance of {@link BasicLink }
     * 
     */
    public BasicLink createBasicLink() {
        return new BasicLink();
    }

    /**
     * Create an instance of {@link BidiOverride }
     * 
     */
    public BidiOverride createBidiOverride() {
        return new BidiOverride();
    }

    /**
     * Create an instance of {@link InlineContainer }
     * 
     */
    public InlineContainer createInlineContainer() {
        return new InlineContainer();
    }

    /**
     * Create an instance of {@link Block }
     * 
     */
    public Block createBlock() {
        return new Block();
    }

    /**
     * Create an instance of {@link InitialPropertySet }
     * 
     */
    public InitialPropertySet createInitialPropertySet() {
        return new InitialPropertySet();
    }

    /**
     * Create an instance of {@link MultiToggle }
     * 
     */
    public MultiToggle createMultiToggle() {
        return new MultiToggle();
    }

    /**
     * Create an instance of {@link BlockContainer }
     * 
     */
    public BlockContainer createBlockContainer() {
        return new BlockContainer();
    }

    /**
     * Create an instance of {@link Table }
     * 
     */
    public Table createTable() {
        return new Table();
    }

    /**
     * Create an instance of {@link TableColumn }
     * 
     */
    public TableColumn createTableColumn() {
        return new TableColumn();
    }

    /**
     * Create an instance of {@link TableHeader }
     * 
     */
    public TableHeader createTableHeader() {
        return new TableHeader();
    }

    /**
     * Create an instance of {@link TableRow }
     * 
     */
    public TableRow createTableRow() {
        return new TableRow();
    }

    /**
     * Create an instance of {@link TableCell }
     * 
     */
    public TableCell createTableCell() {
        return new TableCell();
    }

    /**
     * Create an instance of {@link ListBlock }
     * 
     */
    public ListBlock createListBlock() {
        return new ListBlock();
    }

    /**
     * Create an instance of {@link ListItem }
     * 
     */
    public ListItem createListItem() {
        return new ListItem();
    }

    /**
     * Create an instance of {@link ListItemLabel }
     * 
     */
    public ListItemLabel createListItemLabel() {
        return new ListItemLabel();
    }

    /**
     * Create an instance of {@link TableAndCaption }
     * 
     */
    public TableAndCaption createTableAndCaption() {
        return new TableAndCaption();
    }

    /**
     * Create an instance of {@link TableCaption }
     * 
     */
    public TableCaption createTableCaption() {
        return new TableCaption();
    }

    /**
     * Create an instance of {@link Wrapper }
     * 
     */
    public Wrapper createWrapper() {
        return new Wrapper();
    }

    /**
     * Create an instance of {@link RetrieveMarker }
     * 
     */
    public RetrieveMarker createRetrieveMarker() {
        return new RetrieveMarker();
    }

    /**
     * Create an instance of {@link MultiSwitch }
     * 
     */
    public MultiSwitch createMultiSwitch() {
        return new MultiSwitch();
    }

    /**
     * Create an instance of {@link MultiCase }
     * 
     */
    public MultiCase createMultiCase() {
        return new MultiCase();
    }

    /**
     * Create an instance of {@link MultiProperties }
     * 
     */
    public MultiProperties createMultiProperties() {
        return new MultiProperties();
    }

    /**
     * Create an instance of {@link MultiPropertySet }
     * 
     */
    public MultiPropertySet createMultiPropertySet() {
        return new MultiPropertySet();
    }

    /**
     * Create an instance of {@link Float }
     * 
     */
    public Float createFloat() {
        return new Float();
    }

    /**
     * Create an instance of {@link Footnote }
     * 
     */
    public Footnote createFootnote() {
        return new Footnote();
    }

    /**
     * Create an instance of {@link FootnoteBody }
     * 
     */
    public FootnoteBody createFootnoteBody() {
        return new FootnoteBody();
    }

    /**
     * Create an instance of {@link ListItemBody }
     * 
     */
    public ListItemBody createListItemBody() {
        return new ListItemBody();
    }

    /**
     * Create an instance of {@link TableFooter }
     * 
     */
    public TableFooter createTableFooter() {
        return new TableFooter();
    }

    /**
     * Create an instance of {@link TableBody }
     * 
     */
    public TableBody createTableBody() {
        return new TableBody();
    }

    /**
     * Create an instance of {@link StaticContent }
     * 
     */
    public StaticContent createStaticContent() {
        return new StaticContent();
    }

    /**
     * Create an instance of {@link Flow }
     * 
     */
    public Flow createFlow() {
        return new Flow();

Nicolas Peru

unread,
Sep 7, 2015, 5:41:55 AM9/7/15
to sharmaa...@gmail.com, SonarQube
Hi, 

Thanks for the source code. 

Problem comes from the lines : 
public Character createCharacter() {
        return new Character();
 }

This class is (I guess) a class from your project. I suspect that you do not provide the bytecode of this class to the analysis (via sonar.java.libraries or sonar.java.binaries) and so it is resolved as java.lang.Character and we assume that every constructor of this class has one argument which is not the case here (because of the wrong resolution). 

This result in the NullPointerException you see. 
In order to fix the issue on your project, please configure it properly to provide the bytecode files to the analysis.
Ticket created to fix the issue : https://jira.sonarsource.com/browse/SONARJAVA-1252

Thanks for reporting this !
Cheers,


Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


sharmaa...@gmail.com

unread,
Sep 7, 2015, 8:20:47 AM9/7/15
to SonarQube, sharmaa...@gmail.com
If I use full name of class (along with package), It might solve this issue?

Nicolas Peru

unread,
Sep 7, 2015, 8:30:57 AM9/7/15
to Ankit Sharma, SonarQube
Hi, 
It should work but this is a quite ugly workaround as you will impact your code for a problem of configuration of a tool. 

Cheers,


Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com


sharmaa...@gmail.com

unread,
Sep 8, 2015, 1:08:54 AM9/8/15
to SonarQube, sharmaa...@gmail.com
Hi Nicolas,

Just for testing purpose, I have used full name of Character class, but problem is still same.
I think there is no problem of linking (treating foo.Character class as java.lang.Character class). Problem is something else.
Please let me know, if you are required any other input.
Reply all
Reply to author
Forward
0 new messages