Remote agent crashes when started as Windows service
Asked by Andrey:

Hi, I am having some trouble starting an agent in Windows 7 x64, Java 7.67 (agent 5.4.1, by the way)

Attempted to reinstall, it finishes with no errors. However, when I start the agent from the Windows Services panel, I see the following in the log file:

```
INFO | jvm 1 | 2015/04/03 09:39:20 | 2015-04-03 09:39:20,105 INFO [Thread-1] [BambooActiveMQConnectionFactory] Broker URI: tcp://build.*******.lan:54663?wireFormat.maxInactivityDuration=300000 is valid.INFO | jvm 1 | 2015/04/03 09:39:21 | 2015-04-03 09:39:20,985 ERROR [Thread-1] [EventPublisherImpl] There was an exception thrown trying to dispatch event 'com.atlassian.plugin.event.events.PluginFrameworkStartingEvent@2ea57165' from the invoker 'com.atlassian.plugin.event.impl.MethodSelectorListenerHandler$1$1@2fe8579e'.INFO   | jvm 1    | 2015/04/03 09:39:21 | java.lang.RuntimeException: java.util.ArrayList cannot be cast to [Ljava.lang.Class;INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.event.impl.MethodSelectorListenerHandler$1$1.invoke(MethodSelectorListenerHandler.java:67)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2$1.run(AsynchronousAbleEventDispatcher.java:44)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:29)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.dispatch(AsynchronousAbleEventDispatcher.java:90)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.event.internal.EventPublisherImpl.invokeListeners(EventPublisherImpl.java:151)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.event.internal.EventPublisherImpl.publish(EventPublisherImpl.java:70)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.event.impl.DefaultPluginEventManager.broadcast(DefaultPluginEventManager.java:84)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.manager.DefaultPluginManager.init(DefaultPluginManager.java:149)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at java.lang.reflect.Method.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1237)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1203)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1167)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:267)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1095)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:857)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:122)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:88)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.bamboo.v2.build.agent.remote.RemoteAgent.initApplicationContext(RemoteAgent.java:160)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.bamboo.v2.build.agent.remote.RemoteAgent.start(RemoteAgent.java:53)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at java.lang.reflect.Method.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.bamboo.agent.bootstrap.AgentRunner.run(AgentRunner.java:28)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at java.lang.Thread.run(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | Caused by: java.lang.reflect.InvocationTargetExceptionINFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at java.lang.reflect.Method.invoke(Unknown Source)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.event.impl.MethodSelectorListenerHandler$1$1.invoke(MethodSelectorListenerHandler.java:49)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	... 40 moreINFO   | jvm 1    | 2015/04/03 09:39:21 | Caused by: java.lang.ClassCastException: java.util.ArrayList cannot be cast to [Ljava.lang.Class;INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.spring.SpringHostComponentProviderFactoryBean$SpringHostComponentProvider.provideBeans(SpringHostComponentProviderFactoryBean.java:153)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.spring.SpringHostComponentProviderFactoryBean$SpringHostComponentProvider.provide(SpringHostComponentProviderFactoryBean.java:122)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager.collectHostComponents(FelixOsgiContainerManager.java:482)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager.start(FelixOsgiContainerManager.java:241)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	at com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager.onStart(FelixOsgiContainerManager.java:203)INFO   | jvm 1    | 2015/04/03 09:39:21 | 	... 45 more
```

And then it continues failing to load plugins:

```
C:\bamboo\agent0\plugins\system-provided\bamboo-tomcat-plugin-5.0.2.jar (1393280120984)INFO   | jvm 1    | 2015/04/03 09:39:21 | java.lang.IllegalStateException: Unable to create a tracker when osgi is not running...INFO   | jvm 1    | 2015/04/03 09:39:21 | 2015-04-03 09:39:21,886 ERROR [Thread-1] [ScanningPluginLoader] Unable to deploy plugin 'com.atlassian.bamboo.plugins.maven', file Unit: C:\bamboo\agent0\plugins\system-provided\atlassian-bamboo-plugin-maven-5.4.1.jar (1393453012808)INFO   | jvm 1    | 2015/04/03 09:39:21 | java.lang.IllegalStateException: Unable to create a tracker when osgi is not running
```

The same thing happens if I run *StartBambooAgent-NT.bat* from the bin directory. However, the agent does run if I use *BambooAgent.bat.*It seems to me that the initial exception is bringing the agent down:

*INFO \| jvm 1 \| 2015/04/03 09:39:21 \| 2015-04-03 09:39:20,985 ERROR \[Thread-1\] \[EventPublisherImpl\] There was an exception thrown trying to dispatch event 'com.atlassian.plugin.event.events.PluginFrameworkStartingEvent@2ea57165' from the invoker 'com.atlassian.plugin.event.impl.MethodSelectorListenerHandler$1$1@2fe8579e'.*

What is going on here? Firewall/antivirus issues or Java?


Answers:
author: Sergey Podobry _Stellarity Software_
body: Hi Andrey,

It looks like as a service your agent uses Java 8. Please check this idea.

comments: author: Andrey
body: Thanks for the suggestion. I updated to 8.40, made sure my JAVA_PATH variable was pointing to the new version, tried running the service under my username, and it still crashes. I might try an install in a different directory.


author: Sergey Podobry _Stellarity Software_
body: @Andrey The point is that your Bamboo doesn't support Java 8. Use Java 7 or update your Bamboo.


author: Martin Stoufer
body: Spot on Sergey! Somehow a new 1.8 JDK got added during a bout of updates and there was no explicit JAVA_HOME set for this user.


author: Robart Cliyt
body: Windows 10, the Blue Screen looks the equivalent as in Windows 8/8.1. It's that screen with the scowl emoji and the message.Y our PC kept running into an issue.T his screen seems more neighborly than the first Blue Screens, nevertheless a genuinely amicable screen would reveal to you what made the issue and how to settle it approximately that would not be bothersome since maximum BSODs are triggered by grown into disruption unknown drivers that are recurrently effectually famous by the MS Windows debugger. <http://360totalsecurity.antivirushelplineaustralia.com/360-total-security-technical-support/>