java.lang.ClassCastException:org.quartz.simpl.SimpleThreadPool无法强制转换为org.quartz.spi.ThreadPool

时间:2015-09-27 17:04:58

标签: spring spring-integration spring-xd

我正在Spring Xd中创建自定义模块(接收器)。我需要以4小时的固定间隔创建文件,要么我收到数据,要么不在http源接收数据。我正在使用quartz-2.2.1.jar使用spring-xd-1.2.0.RELEASE-dist和我的配置xml看起来像这样

<int:channel id="input" />

<int:channel id="output" />

<int:transformer input-channel="input"
    ref="edwSinkImpl" output-channel="output" />


<bean name="edwSinkImpl"
    class="com.xd.edwsink.impl.EdwSinkImpl">
    <property name="eDWUtil" ref="eDWUtil" />
</bean>

<bean name="eDWUtil"
    class="com.xd.edwsink.util.EDWUtil" scope="singleton">
    <property name="directory" value="C:\\tmp\\" />
    <property name="timeFormat" value="HHmmss" />
    <property name="fileAge" value="4" />
    <property name="filePrefix" value="OB" />
    <property name="fileExt" value="dat" />
    <property name="stagingFileExt" value="stage" />
    <property name="dateFormat" value="MMddyyyy" />
    <property name="deliMeter" value="," />
</bean>

<bean name="fileRotatorJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
    <property name="jobClass" value="com.xd.edwsink.impl.FileRotatorJob" />
    <property name="jobDataAsMap">
        <map>
            <entry key="util" value-ref="eDWUtil" />
        </map>
    </property>
    <property name="durability" value="true" />
</bean>

<bean id="fileRotationCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    <property name="jobDetail" ref="fileRotatorJob" />
    <property name="cronExpression" value="0 0 0/4 * * ?" /> 
</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="jobDetails">
        <list>
            <ref bean="fileRotatorJob" />
        </list>
    </property>
    <property name="triggers">
        <list>
            <ref bean="fileRotationCronTrigger" />
        </list>
    </property>
</bean>

在spring-xd env外部运行时代码运行正常但在SringXd环境中运行时出现以下错误

modules\sink\edw-outbound-sink\config\edw-outbound-sink.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerException: ThreadPool class 'org.quartz.simpl.SimpleThreadPool' could not be i
nstantiated. [See nested exception: java.lang.ClassCastException: org.quartz.simpl.SimpleThreadPool cannot be cast to org.quartz.spi.ThreadPool]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139)
        at org.springframework.xd.module.core.SimpleModule.initialize(SimpleModule.java:213)
        at org.springframework.xd.dirt.module.ModuleDeployer.doDeploy(ModuleDeployer.java:217)
        at org.springframework.xd.dirt.module.ModuleDeployer.deploy(ModuleDeployer.java:200)
        at org.springframework.xd.dirt.server.container.DeploymentListener.deployModule(DeploymentListener.java:365)
        at org.springframework.xd.dirt.server.container.DeploymentListener.deployStreamModule(DeploymentListener.java:334)
        at org.springframework.xd.dirt.server.container.DeploymentListener.onChildAdded(DeploymentListener.java:181)
        at org.springframework.xd.dirt.server.container.DeploymentListener.childEvent(DeploymentListener.java:149)
        at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:509)
        at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:503)
        at org.apache.curator.framework.listen.ListenerContainer$1.run(ListenerContainer.java:92)
        at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297)
        at org.apache.curator.framework.listen.ListenerContainer.forEach(ListenerContainer.java:83)
        at org.apache.curator.framework.recipes.cache.PathChildrenCache.callListeners(PathChildrenCache.java:500)
        at org.apache.curator.framework.recipes.cache.EventOperation.invoke(EventOperation.java:35)
        at org.apache.curator.framework.recipes.cache.PathChildrenCache$10.run(PathChildrenCache.java:762)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.quartz.SchedulerException: ThreadPool class 'org.quartz.simpl.SimpleThreadPool' could not be instantiated. [See nested exception: java.lang.ClassCastException: org.quartz.simpl.SimpleThreadPool canno
t be cast to org.quartz.spi.ThreadPool]
        at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:843)
        at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1519)
        at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler(SchedulerFactoryBean.java:597)
        at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:480)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
        ... 34 more
Caused by: java.lang.ClassCastException: org.quartz.simpl.SimpleThreadPool cannot be cast to org.quartz.spi.ThreadPool
        at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:841)
        ... 39 more
}

0 个答案:

没有答案