0

I'm creating custom module(sink) in spring Xd.I need to create file at regular interval of 4 hrs either i receive data or donot receive data at http source.I'm using quartz-2.2.1.jar with spring-xd-1.2.0.RELEASE-dist and my config xml looks like this

<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>

Code works perfectly fine when run outside spring-xd env but in SringXd env env i get following error

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
}
Ruben
  • 3,986
  • 1
  • 21
  • 34
hunter
  • 13
  • 3
  • You're using incompatible versions of the jars (or at least one of the jars in your classpath is incompatible). Check which version of quartz is compatible with your version of spring-xd. – Augusto Sep 27 '15 at 17:07
  • Sounds like a duplicate of http://stackoverflow.com/questions/32544256/springxd-classcastexception-of-same-class-between-modules-in-a-stream/32550003#32550003 – dturanski Sep 27 '15 at 18:23
  • Thanks for pointing to the above link. Issue is resolved. quartz-2.2.1.jar is compatible with spring-xd-1.2.0.RELEASE-dist. All i did was copied quartz-2.2.1.jar to xd/lib folder and removed it from custom module lib. – hunter Sep 27 '15 at 19:17

0 Answers0