Launching job from Tomcat
I'm trying to launch a job from Tomcat. After someone hits my URL, it fires off this process. Running as a standalone JavaSE application, it works fine. However, when running on Tomcat, it seems like it cannot create certain beans. Any ideas? Does it have to do with paths to the xml files or anything?
Code:
final String[] paths = new String[] { "resources/jobs/feedreader.xml", "simple-container-definition.xml" };
try {
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(paths);
JobLauncher jobLauncher = (JobLauncher) applicationContext.getBean("jobLauncher");
Job job = (Job) applicationContext.getBean("feedreader");
jobLauncher.run(job, new JobParameters());
} catch (Exception ex) {
mLogger.error("error trying to run job");
ex.printStackTrace();
}
Gives:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jobLauncher' defined in class path resource [simple-container-definition.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1362)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:540)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 51)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:169)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeansOfType(DefaultListableB eanFactory.java:296)
at org.springframework.context.support.AbstractApplic ationContext.getBeansOfType(AbstractApplicationCon text.java:950)
at org.springframework.context.support.AbstractApplic ationContext.registerListeners(AbstractApplication Context.java:711)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:366)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:122)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:76)