Not possible to access project issues using web api

sonarqube

(André Krautschick) #1

We’re currently using Sonarqube 6.7.4 (LTS) with a PostgreSQL database (Version 9.2.23) on Red Hat 7.4.
When trying to access one of our projects via the web api following exception is thrown:

2018.06.26 07:03:10 ERROR web[AWQ25OLop+Ezebt/AAPS][o.s.s.w.WebServiceEngine] Fail to process request http://127.0.0.1:9000/batch/issues?key=mps
org.apache.ibatis.exceptions.PersistenceException:
\### The error occurred while handling results
\### SQL: select           i.id,     i.kee as kee,     i.rule_id as ruleId,     i.severity as severity,     i.manual_severity as manualSeverity,     i.message as message,     i.line as line,     i.locations as locations,     i.gap as gap,     i.effort as effort,     i.status as status,     i.resolution as resolution,     i.checksum as checksum,     i.assignee as assignee,     i.author_login as authorLogin,     i.tags as tagsString,     i.issue_attributes as issueAttributes,     i.issue_creation_date as issueCreationTime,     i.issue_update_date as issueUpdateTime,     i.issue_close_date as issueCloseTime,     i.created_at as createdAt,     i.updated_at as updatedAt,     r.plugin_rule_key as ruleKey,     r.plugin_name as ruleRepo,     r.language as language,     p.kee as componentKey,     i.component_uuid as componentUuid,     p.module_uuid as moduleUuid,     p.module_uuid_path as moduleUuidPath,     p.path as filePath,     root.kee as projectKey,     i.project_uuid as projectUuid,     i.issue_type as type         from issues i     inner join rules r on r.id = i.rule_id     inner join projects p on p.uuid = i.component_uuid     inner join projects root on root.uuid = i.project_uuid     where     i.project_uuid = ? and     p.module_uuid_path like  ? escape '/' and     i.status <> 'CLOSED'
\### Cause: java.lang.NullPointerException
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.select(DefaultSqlSession.java:172)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.select(DefaultSqlSession.java:158)
        at org.apache.ibatis.binding.MapperMethod.executeWithResultHandler(MapperMethod.java:126)
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:72)
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
        at com.sun.proxy.$Proxy62.scrollNonClosedByModuleOrProject(Unknown Source)
        at org.sonar.db.issue.IssueDao.scrollNonClosedByModuleOrProject(IssueDao.java:103)
        at org.sonar.server.batch.IssuesAction.handle(IssuesAction.java:105)
        at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:103)
        at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:86)
        at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126)
        at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:95)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:87)
        at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:71)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.sonar.server.platform.web.SecurityServletFilter.doHttpFilter(SecurityServletFilter.java:72)
        at org.sonar.server.platform.web.SecurityServletFilter.doFilter(SecurityServletFilter.java:48)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.sonar.server.platform.web.RedirectFilter.doFilter(RedirectFilter.java:61)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.sonar.server.platform.web.requestid.RequestIdFilter.doFilter(RequestIdFilter.java:63)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:62)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: null
        at org.sonar.scanner.protocol.input.ScannerInput$ServerIssue$Builder.setModuleKey(ScannerInput.java:1475)
        at org.sonar.server.batch.IssuesAction.handleIssue(IssuesAction.java:121)
        at org.sonar.server.batch.IssuesAction.lambda$handle$0(IssuesAction.java:101)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.callResultHandler(DefaultResultSetHandler.java:363)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.storeObject(DefaultResultSetHandler.java:356)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:348)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:322)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:298)
        at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:192)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
        at org.apache.ibatis.executor.ReuseExecutor.doQuery(ReuseExecutor.java:60)
        at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.select(DefaultSqlSession.java:170)
        ... 49 common frames omitted

When calling the web api manually following output is generated:
{"errors":[{"msg":"An error has occurred. Please contact your administrator"}]}

This is currently happening for two of our projects.

Best regards
André


(Paul Hamer) #2

This appears to happen only for projects that have subprojects/modules


(G Ann Campbell) #3

Hi,

Can you see these projects’ issues through the UI?

Ann


(Paul Hamer) #4

The Sonarqube web UI shows no obvious problems. We can all see the issues and manage them, so that seems just fine.


(G Ann Campbell) #5

Hi,

To be clear, you can successfully browse via the UI all the issues of the project you’re having trouble with via Web Services?

Can you share your web service call? And could you use your browser’s dev tools to compare the call you’re making with the one that’s successful from your browser?

Ann


(André Krautschick) #6

Hi,

following web service call is causing trouble:
https://<sonarqub-server>:9000/batch/issues?key=<projectname>

The UI is using following succesful call to get the issues:
https://<sonarqub-server>:9000/project/issues?id=<projectname>&resolved=false

André


(Emre Dundar) #7

Hi André,

You can try this api call to list unresolved issues of a project:
https://<sonarqub-server>:9000/api/issues/search?componentKeys=<projectname>&resolved=false

Documentation: http://localhost:9000/web_api/api/issues/search


(Janos Gyerik) #8

@akrautsc @HammerNL do you get this issue during the analysis of a multi-module project? How exactly do you run the analysis?


(Paul Hamer) #11

The Sonarqube UI is not showing any problems, everything seems to work fine. We can browse and manage all the issues just fine.
We can not show you the code of the web service call, because that call is done by the SonarLint plugin for IntelliJ IDEA. However, that is not relevant, because the problem also occurs when I simply visit this URL in a browser:

https://<sonarqube-server>:9000/batch/issues?key=<projectname>

I then see in the browser:

{“errors”:[{“msg”:“An error has occurred. Please contact your administrator”}]}

In the Sonarqube server logging we then find the NullPointerException posted by André above. If I change the projectname to that of a project without modules, the output is OK.

This call works fine indeed, however, we are not at liberty to just use a different URL, because it is done by the SonarLint plugin for IntelliJ IDEA.

We run the analysis in two different ways.
1: The analysis is started from Jenkins, in which case,everything works fine
2: In our IntelliJ IDEA development environment we want to use the SonarLint plugin. This plugin is using this URL:

https://<sonarqube-server>:9000/batch/issues?key=<projectname>

to get information from the Sonarqube server. This URL access causes the NullPointerException that my colleague André posted in this threads first post. If I change the projectname in the URL to that of a project without modules, the output is OK.

HTH!


(Julien Lancelot) #12

Hi,

As your issue is about retrieving issues from a given module (having key mps from the error log ), could you please go to the Issues page of the project, select the module in the Module facet and check if you have access to the issues of the module ?

Regards


(Paul Hamer) #13

As mentioned several times before, I can properly access all issues of the project and any of its modules via the Sonarqube web UI. So yes, I can select a module and I then get the issues for that module. Works fine.