Sonar - Fail to request server version | HTTP Status 404

一个人想着一个人 提交于 2019-12-07 18:52:19

问题


I'm setting up a sonar system for Java. My local test SonarServer 4.0 successfully connect and process my antscript (I'm using "sonar-ant-task-2.2.jar"). But my target server 3.7.3 won't even provide the server version.

I tried the given http://... from the given errormessage and my browser (firefox) is showing the correct server version.

Can someone help me out with this one ? Thx :)

PATH2ANTSCRIPT\build.xml:159: java.lang.IllegalStateException: Fail to request server version
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:392)
    at org.apache.tools.ant.Target.performTasks(Target.java:413)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
    at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: java.lang.IllegalStateException: Fail to request server version
    at org.sonar.runner.impl.ServerVersion.downloadVersion(ServerVersion.java:49)
    at org.sonar.runner.impl.ServerVersion.version(ServerVersion.java:38)
    at org.sonar.runner.impl.ServerVersion.is37Compatible(ServerVersion.java:58)
    at org.sonar.runner.impl.JarDownloader.checkVersionAndDownload(JarDownloader.java:36)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:71)
    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.ant.SonarTask.launchAnalysis(SonarTask.java:53)
    at org.sonar.ant.SonarTask.execute(SonarTask.java:48)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    ... 10 more
Caused by: java.io.IOException: Status returned by url : 'http://URL2SERVER.net/sonar/api/server/version' is invalid : 404
    at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:94)
    at org.sonar.runner.impl.ServerVersion.downloadVersion(ServerVersion.java:47)
    ... 26 more

EDIT: Sorry but after a restart I can't reproduce this error above. Now I can't even connect to the server :O After some restarts later I still get this error - for not connecting

BUILD FAILED
PATH2ANTSCRIPT\build.xml:160: org.sonar.runner.kevinsawicki.HttpRequest$HttpRequestException: java.net.ConnectException: Connection timed out: connect
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
        at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:392)
    at org.apache.tools.ant.Target.performTasks(Target.java:413)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
    at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
Caused by: org.sonar.runner.kevinsawicki.HttpRequest$HttpRequestException: java.net.ConnectException: Connection timed out: connect
    at org.sonar.runner.kevinsawicki.HttpRequest.code(HttpRequest.java:1392)
    at org.sonar.runner.kevinsawicki.HttpRequest.ok(HttpRequest.java:1417)
    at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:93)
    at org.sonar.runner.impl.ServerVersion.downloadVersion(ServerVersion.java:47)
    at org.sonar.runner.impl.ServerVersion.version(ServerVersion.java:38)
    at org.sonar.runner.impl.ServerVersion.is37Compatible(ServerVersion.java:58)
    at org.sonar.runner.impl.JarDownloader.checkVersionAndDownload(JarDownloader.java:36)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:71)
    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.ant.SonarTask.launchAnalysis(SonarTask.java:53)
    at org.sonar.ant.SonarTask.execute(SonarTask.java:48)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
... 10 more
Caused by: java.net.ConnectException: Connection timed out: connect
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    at org.sonar.runner.kevinsawicki.HttpRequest.code(HttpRequest.java:1390)
... 29 more
Caused by: java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.<init>(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
    at org.sonar.runner.kevinsawicki.HttpRequest.header(HttpRequest.java:1903)
    at org.sonar.runner.kevinsawicki.HttpRequest.contentType(HttpRequest.java:2308)
    at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:89)
... 27 more

回答1:


seems that your server can not connect, you can do the two following operation: 1. check your sonar server port had been listening.. 2. restart the sonar server, if your environment need mysql first, restart mysql first.




回答2:


I don't know how, but the server was secured to allow only http requests. So the problem was an adminstration problem only.




回答3:


I too had the same issue and resolved it. Check the SonarQube server's following properties (you may find it in - SONAR_INSTALATION_DIR/conf/sonar.properties)

sonar.web.host=localhost
sonar.web.port=9000
sonar.web.context=/sonar

Then check your Sonar-runner's configuration(You may find it in - SONAR-RUNNER-INSTALLATION-DIR/conf/sonar-runner.properties)

sonar.host.url=http://localhost:9000/sonar

Make sure the sonar.host.url was composed using the above three properties from the SonarQube's properties as shown here. In your case make sure you have the values as explained here.



来源:https://stackoverflow.com/questions/24889962/sonar-fail-to-request-server-version-http-status-404

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!