tcplugins/tcWebHooks

Failed to Initialize Spring Context

michaelpbean opened this issue · 9 comments

Expected Behavior

Successful installation

Current Behavior

Error when installing tcWebHooks-REST-API-1.2.0-alpha.7-build.382.zip plugin

Failed to initialize Spring Context:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webHookTeamCityRestApiZipPluginFixer' defined in Byte array resource [plugin: tcWebHooks-rest-api#tcwebhooks-rest-api-1.2.0-alpha.7-build.382-jar-with-dependencies.jar!/META-INF/build-server-plugin-RESTListener.xml]: Invocation of init method failed; nested exception is java.nio.file.FileSystemNotFoundException: C:\Program%20Files\TeamCity\webapps\ROOT\WEB-INF\plugins\rest-api.zip
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1619)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:757)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at jetbrains.buildServer.plugins.spring.SpringPluginLoader.pluginClassesLoaded(SpringPluginLoader.java:124)
at jdk.internal.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at jetbrains.buildServer.util.EventDispatcher$3.run(EventDispatcher.java:138)
at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:76)
at jetbrains.buildServer.util.EventDispatcher.dispatch(EventDispatcher.java:132)
at jetbrains.buildServer.util.EventDispatcher$2.invoke(EventDispatcher.java:82)
at com.sun.proxy.$Proxy25.pluginClassesLoaded(Unknown Source)
at jetbrains.buildServer.plugins.PluginManagerImpl$5.visitPlugin(PluginManagerImpl.java:441)
at jetbrains.buildServer.plugins.PluginsCollection.foreachLoadedPluginsAsync(PluginsCollection.java:114)
at jetbrains.buildServer.plugins.PluginManagerImpl.firePluginClassesLoaded(PluginManagerImpl.java:438)
at jetbrains.buildServer.plugins.PluginManagerImpl.doLoadPluginsCollection(PluginManagerImpl.java:381)
at jetbrains.buildServer.plugins.PluginManagerImpl.loadPlugins(PluginManagerImpl.java:349)
at jetbrains.buildServer.web.plugins.PluginManagerConfigurator.initializePlugins(PluginManagerConfigurator.java:24)
at jetbrains.buildServer.web.impl.BuildServerConfigurator.loadConfiguration(BuildServerConfigurator.java:35)
at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:807)
at jetbrains.buildServer.serverSide.impl.BuildServerLifecycleProcessor.doStartup(BuildServerLifecycleProcessor.java:21)
at jetbrains.buildServer.maintenance.TeamCityDispatcherServlet$WebApplicationCreatorAndDestroyer.createApplication(TeamCityDispatcherServlet.java:6)
at jetbrains.buildServer.maintenance.StartupProcessor.doApplicationStarting(StartupProcessor.java:814)
at jetbrains.buildServer.maintenance.StartupProcessor.access$1800(StartupProcessor.java:1196)
at jetbrains.buildServer.maintenance.StartupProcessor$3.call(StartupProcessor.java:18)
at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:91)
at jetbrains.buildServer.maintenance.StartupProcessor.processConcreteStage(StartupProcessor.java:1312)
at jetbrains.buildServer.maintenance.StartupProcessor.processConcreteStageSafe(StartupProcessor.java:288)
at jetbrains.buildServer.maintenance.StartupProcessor.processTeamCityLifecycle(StartupProcessor.java:1219)
at jetbrains.buildServer.maintenance.StartupProcessor.access$000(StartupProcessor.java:819)
at jetbrains.buildServer.maintenance.StartupProcessor$1.run(StartupProcessor.java:3)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.file.FileSystemNotFoundException: C:\Program%20Files\TeamCity\webapps\ROOT\WEB-INF\plugins\rest-api.zip
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.(ZipFileSystem.java:118)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:109)
at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:337)
at java.base/java.nio.file.FileSystems.newFileSystem(FileSystems.java:286)
at webhook.teamcity.server.WebHookTeamCityRestApiZipPluginFixer.doesRestApiZipFileContainJaxJars(WebHookTeamCityRestApiZipPluginFixer.java:227)
at webhook.teamcity.server.WebHookTeamCityRestApiZipPluginFixer.findRestApiZipPlugins(WebHookTeamCityRestApiZipPluginFixer.java:88)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1748)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1685)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1615)
... 38 more

Steps to Reproduce (for bugs)

  1. Upload tcWebHooks-1.2.0-alpha.7-build.382.zip and restart server - this is working fine
  2. Upload tcWebHooks-REST-API-1.2.0-alpha.7-build.382.zip and restart server - produces the above error

Your Environment

  • tcWebHooks Version: 1.2.0-alpha.7-build.382
  • TeamCity Version: 2021.1.3 (build 92914)
  • TeamCity server Operating System: Windows 10
  • Are you using a WebHook Template?: Currently using built-in Slack.com Compact Notification (JSON Standard template), but want to copy/customize it.

Example Configuration (xml)

It's a wild guess, but part of the error above is FileSystemNotFoundException on C:\Program%20Files\TeamCity\webapps\ROOT\WEB-INF\plugins\rest-api.zip. This may not be a valid Windows path and should be:

"C:\Program Files\TeamCity\webapps\ROOT\WEB-INF\plugins\rest-api.zip"

-or-

C:\Progra~1\TeamCity\webapps\ROOT\WEB-INF\plugins\rest-api.zip

Hi @michaelpbean

I've not seen this one before. Can I get a bit more detail please?

  • Windows version
  • Java version
  • does the rest-api.zip file exist?

Since about TC 2020.1, the problem with the existing jars conflicting has been resolved, so I should really check the TC version and then skip the step of validating the plugin.

  • Windows 10 Version 20H2 (Build 19042.1237)
  • Java Version 8 Update 251 (Build 1.8.0_251-b08)
  • And yes rest-api.zip exists at that path, and can be found with either path I mentioned, but not with %20 for the space in "Program Files".

Thanks @michaelpbean Yes, I suspect you are right. It appears to be Java being silly and treating paths as URL like objects. I'm looking into whether I can just skip this check for 2021.x

A workaround is building now. I'll post the link shortly

Can you please try a build from here @michaelpbean

https://teamcity.jetbrains.com/buildConfiguration/WebHooksAndOtherPlugins_TcWebHooks?branch=bugfix%2Fdisable-jar-checking-for-new-teamcity-versions&buildTypeTab=overview&mode=builds

It's alpha7 patched so that it does not attempt to do the rest-api.zip checking for newer TC versions.
Just login as guest in TC.

Yeah, that worked. Thanks for the quick fix!

Great. I'll merge that to master when I'm back at the computer so that it's there on the next release.

BTW

It appears to be Java being silly and treating paths as URL like objects.

I found the code in question. It's me being silly and converting it to a URL. That's because the library I am using takes a URL as the input. Oh well. I can't blame Java for that. 😉