I'm trying to use the CommonJ WorkManagerTaskExecutor
as the task executor for a Quartz SchedulerFactoryBean
in order to avoid unmanaged threads in WebSphere (described here--scroll down to "Quartz With CommonJ" section). Unfortunately, I can't seem to look up any of the default WebSphere WorkManager
s, nor any that I create. The Spring bean for the CommonJ WorkManager
:
<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
<property name="workManagerName" value="wm/default" />
</bean>
I'm getting a ServiceNotInitializedException: AsynchBeans Service not initialized
error and stack trace:
Exception in thread "P=166330:O=0:CT" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduler' defined in class path resource [spring-quartz-config.xml]: Cannot resolve reference to bean 'taskExecutor' while setting bean property 'taskExecutor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'taskExecutor' defined in class path resource [spring-quartz-config.xml]: Invocation of init method failed; nested exception is com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is com.ibm.ws.asynchbeans.ServiceNotInitializedException: AsynchBeans Service not initialized]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
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:83)
at com.lmig.am.claims.clip.test.TestQuartz.main(TestQuartz.java:12)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'taskExecutor' defined in class path resource [spring-quartz-config.xml]: Invocation of init method failed; nested exception is com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is com.ibm.ws.asynchbeans.ServiceNotInitializedException: AsynchBeans Service not initialized]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 15 more
Caused by: com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is com.ibm.ws.asynchbeans.ServiceNotInitializedException: AsynchBeans Service not initialized]
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1033)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpers.java:730)
at com.ibm.ws.naming.jndicos.CNContextImpl.processResolveResults(CNContextImpl.java:3678)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1848)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1749)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1500)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:637)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:165)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:436)
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.afterPropertiesSet(WorkManagerTaskExecutor.java:137)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 22 more
Caused by: com.ibm.ws.asynchbeans.ServiceNotInitializedException: AsynchBeans Service not initialized
at com.ibm.ws.asynchbeans.J2EEServiceManager.getSelf(J2EEServiceManager.java:286)
at com.ibm.ws.asynchbeans.AsynchContextDescriptorImpl2.inflateContext(AsynchContextDescriptorImpl2.java:164)
at com.ibm.ws.asynchbeans.AsynchContextDescriptorImpl2.<init>(AsynchContextDescriptorImpl2.java:84)
at com.ibm.ws.asynchbeans.AsynchBeanManager.<init>(AsynchBeanManager.java:150)
at com.ibm.ws.asynchbeans.AsynchBeanManager.<init>(AsynchBeanManager.java:182)
at com.ibm.ws.asynchbeans.AsynchBeanManager.<init>(AsynchBeanManager.java:195)
at com.ibm.ws.asynchbeans.WorkManagerImpl.<init>(WorkManagerImpl.java:190)
at com.ibm.ws.asynchbeans.naming.WorkManagerFactory.createWorkManager(WorkManagerFactory.java:290)
at com.ibm.ws.asynchbeans.naming.WorkManagerFactory.getObjectInstance(WorkManagerFactory.java:205)
at javax.naming.spi.NamingManager.getObjectInstanceByFactoryInReference(NamingManager.java:485)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:350)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:927)
... 39 more
Any ideas what I can do to resolve this? Thanks!
WebSphere asynchbeans can only be used from an application server process. From the stack trace, you're attempting to use it from a TestQuartz main method that you've written, and asynchbeans is throwing an exception to indicate that it was not started in that JVM as part of server initialization.