Unexpected Error when calling REST API

Hi,

I need help accessing the REST API using the current version of TeamCity. All those URLs:
/app/rest/
/httpAuth/app/rest
/httpAuth/app/rest/server
/httpAuth/app/rest/users
/httpAuth/app/rest/v2/users
/httpAuth/app/rest/application.wadl

return the same error page:

Unexpected Error

This was not supposed to happen. Please provide the error details to your TeamCity server maintainer.
If you maintain this TeamCity installation please report this error to JetBrains.

Error message: The scope of the component class jetbrains.buildServer.server.rest.jersey.UrlBuilderProvider must be a singleton
TeamCity: 9.0.1 (build 32116)
Operating system: Windows Server 2008 R2 (6.1, x86)
Java: 1.7.0_72-b14 (Oracle Corporation)
Servlet container: Apache Tomcat/7.0.57

Trace: java.lang.RuntimeException: The scope of the component class jetbrains.buildServer.server.rest.jersey.UrlBuilderProvider must be a singleton
     at com.sun.jersey.core.spi.component.ioc.IoCProviderFactory.wrap(IoCProviderFactory.java:99)
     at com.sun.jersey.core.spi.component.ioc.IoCProviderFactory._getComponentProvider(IoCProviderFactory.java:90)
     at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:150)
     at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:128)
     at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:233)
     at com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndServices(ProviderServices.java:182)
     at com.sun.jersey.core.spi.factory.InjectableProviderFactory.configure(InjectableProviderFactory.java:104)
     at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:580)
     at jetbrains.buildServer.server.rest.jersey.JerseyWebComponent.initiate(JerseyWebComponent.java:43)
     at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:253)
     at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:517)
     at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:199)
     at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:308)
     at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:642)
     at jetbrains.buildServer.server.rest.APIController.init(APIController.java:154)
     at jetbrains.buildServer.server.rest.APIController.ensureInitialized(APIController.java:293)
     at jetbrains.buildServer.server.rest.APIController.doHandle(APIController.java:203)
     at jetbrains.buildServer.controllers.BaseController.handleRequestInternal(BaseController.java:75)
     at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:154)
     at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
     at jetbrains.buildServer.maintenance.TeamCityDispatcherServlet.service(TeamCityDispatcherServlet.java:3)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
     at jetbrains.buildServer.web.DependencyParametersCalculationContextFilter.doFilter(DependencyParametersCalculationContextFilter.java:11)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
     at jetbrains.buildServer.web.DisableSessionIdFromUrlFilter.doFilter(DisableSessionIdFromUrlFilter.java:5)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
     at jetbrains.buildServer.diagnostic.web.DiagnosticFilter.doFilter(DiagnosticFilter.java:12)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
     at java.lang.Thread.run(Thread.java:745)



The "Basic HTTP" module is enabled. Restarting the server or the Teamcity service doesn't help.
teamcity-rest.log only contains
[2015-01-21 13:49:34,888]   INFO [15-01-21 13:48)] - er.rest.APIController/rest-api - Listening for paths [/app/rest, /app/rest/latest, /app/rest/9.0, /api] in plugin 'rest-api'
[2015-01-21 13:49:34,888]  ERROR [15-01-21 13:48)] - er.rest.APIController/rest-api - Error registering controller in plugin 'rest-api'
java.lang.IllegalStateException: Cannot map handler of type [class jetbrains.buildServer.server.rest.APIController] to URL path [/httpAuth/app/rest/**]: There is already handler of type [class jetbrains.buildServer.server.rest.APIController] mapped.
...and the same stacktrace

2 comments
Comment actions Permalink

Hi Oliver,

Do you have any non-bundled REST plugins installed (i.e. is <TeamCity Data Directory>\plugins empty on your server)?
If there are some rest plugins, please remove them and restart the server.

If not, please detail your TeamCity installation procedure. Does it reproduce if you run a fresh TeamCity instance?

0
Comment actions Permalink

Hi Yegor,

thanks for pointing me in the right direction, we indeed have the https://github.com/grundic/teamcity-avatar plugin installed and in the plugin folder it was somehow extracted twice. Once into the ".unpacked" folder and once directly into the plugins folder. After removing the unnecessary files the REST API worked again.
Not sure why there was such a mess in that folder. We updated the plugin and the TeamCity version a few times already (no fresh installs), but now at least everything looks good again.

0

Please sign in to leave a comment.