Startup fails when pending foreign-source exists with no pending requisition

Description

Steps to reproduce:

1. On a freshly-installed system, use the web UI requisition editor to create a requisition called "test". Add a node or two (contents are immaterial). Synchronize the requisition.

2. After the requisition is done synchronizing, go back to the Admin / Manage Provisioning Requisitions page. Click the "Edit" link for the foreign-source definition corresponding to the "test" requisition. DO NOT edit the requisition, just the foreign-source definition.

3. In the filesystem, verify that only the foreign-source is pending and not the requisition:

[jeffg@flyingfox ~]$ ls /opt/opennms/etc/foreign-sources/pending/test.xml /opt/opennms/etc/imports/pending/test.xml
ls: cannot access /opt/opennms/etc/imports/pending/test.xml: No such file or directory
/opt/opennms/etc/foreign-sources/pending/test.xml

4. Stop OpenNMS. Remove the logs.

5. Start OpenNMS.

Expected result: a normal, trouble-free startup

Actual result: Failed startup with the following exception stack trace appearing in manager.log:

2013-04-10 12:19:53,155 FATAL [Main] Starter: An error occurred while attempting to start the "OpenNMS:Name=Provisiond" service (class org.opennms.netmgt.daemon.SimpleSpringContextJmxServiceDaemon). Shutting down and exiting.
javax.management.RuntimeMBeanException: org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [provisiondContext], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisiondContext' defined in URL [jar:file:/opt/opennms/lib/opennms-provisiond-1.11.91-SNAPSHOT.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisionService' defined in class path resource [META-INF/opennms/applicationContext-provisiond.xml]: Invocation of init method failed; nested exception is org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException: Requisition: test does not exist.; nested exception is java.io.FileNotFoundException: there is no file test.xml in directory /opt/opennms/etc/imports/pending
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.rethrow(DefaultMBeanServerInterceptor.java:839)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.rethrowMaybeMBeanException(DefaultMBeanServerInterceptor.java:852)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:821)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:792)
at org.opennms.netmgt.vmmgr.Invoker.invoke(Invoker.java:316)
at org.opennms.netmgt.vmmgr.Invoker.invokeMethods(Invoker.java:239)
at org.opennms.netmgt.vmmgr.Starter.start(Starter.java:245)
at org.opennms.netmgt.vmmgr.Starter.startDaemon(Starter.java:116)
at org.opennms.netmgt.vmmgr.Controller.start(Controller.java:190)
at org.opennms.netmgt.vmmgr.Controller.main(Controller.java:162)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.opennms.bootstrap.Bootstrap$3.run(Bootstrap.java:346)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [provisiondContext], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisiondContext' defined in URL [jar:file:/opt/opennms/lib/opennms-provisiond-1.11.91-SNAPSHOT.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisionService' defined in class path resource [META-INF/opennms/applicationContext-provisiond.xml]: Invocation of init method failed; nested exception is org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException: Requisition: test does not exist.; nested exception is java.io.FileNotFoundException: there is no file test.xml in directory /opt/opennms/etc/imports/pending
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:409)
at org.opennms.core.utils.BeanUtils.getBeanFactory(BeanUtils.java:58)
at org.opennms.core.utils.BeanUtils.getFactory(BeanUtils.java:100)
at org.opennms.netmgt.daemon.AbstractSpringContextJmxServiceDaemon.init(AbstractSpringContextJmxServiceDaemon.java:94)
at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:111)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:45)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:235)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
... 13 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisiondContext' defined in URL [jar:file:/opt/opennms/lib/opennms-provisiond-1.11.91-SNAPSHOT.jar!/beanRefContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisionService' defined in class path resource [META-INF/opennms/applicationContext-provisiond.xml]: Invocation of init method failed; nested exception is org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException: Requisition: test does not exist.; nested exception is java.io.FileNotFoundException: there is no file test.xml in directory /opt/opennms/etc/imports/pending
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1002)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:906)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:484)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:397)
... 25 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisionService' defined in class path resource [META-INF/opennms/applicationContext-provisiond.xml]: Invocation of init method failed; nested exception is org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException: Requisition: test does not exist.; nested exception is java.io.FileNotFoundException: there is no file test.xml in directory /opt/opennms/etc/imports/pending
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 35 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'provisionService' defined in class path resource [META-INF/opennms/applicationContext-provisiond.xml]: Invocation of init method failed; nested exception is org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException: Requisition: test does not exist.; nested exception is java.io.FileNotFoundException: there is no file test.xml in directory /opt/opennms/etc/imports/pending
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:105)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 37 more
Caused by: org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException: Requisition: test does not exist.; nested exception is java.io.FileNotFoundException: there is no file test.xml in directory /opt/opennms/etc/imports/pending
at org.opennms.netmgt.provision.persist.FasterFilesystemForeignSourceRepository.getRequisition(FasterFilesystemForeignSourceRepository.java:265)
at org.opennms.netmgt.provision.persist.FasterFilesystemForeignSourceRepository.getRequisitionURL(FasterFilesystemForeignSourceRepository.java:382)
at org.opennms.netmgt.provision.persist.RequisitionFileUtils.findSnapshots(RequisitionFileUtils.java:88)
at org.opennms.netmgt.provision.persist.RequisitionFileUtils.deleteAllSnapshots(RequisitionFileUtils.java:131)
at org.opennms.netmgt.provision.service.DefaultProvisionService.afterPropertiesSet(DefaultProvisionService.java:173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
... 53 more
Caused by: java.io.FileNotFoundException: there is no file test.xml in directory /opt/opennms/etc/imports/pending
at org.opennms.netmgt.provision.persist.DirectoryWatcher.getContents(DirectoryWatcher.java:69)
at org.opennms.netmgt.provision.persist.FasterFilesystemForeignSourceRepository.getRequisition(FasterFilesystemForeignSourceRepository.java:263)
... 59 more

Workaround: put a copy of etc/imports/test.xml into etc/imports/pending/test.xml and startup succeeds.

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Benjamin Reed April 10, 2013 at 4:36 PM

Fixed in 1.12 and up, the util call to clean up snapshots didn't handle the case where a repository doesn't exist (yet).

Fixed

Details

Assignee

Reporter

Fix versions

Affects versions

Priority

PagerDuty

Created April 10, 2013 at 12:26 PM
Updated January 27, 2017 at 4:20 PM
Resolved April 10, 2013 at 4:36 PM