Results 1 to 6 of 6

Thread: Error in definition of default taskScheduler

  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Question Error in definition of default taskScheduler

    Hi,

    I'm trying to supply a "taskScheduler" to my SI implementation, and getting a Class Not Found error for "org.springframework.integration.scheduling.Simple TaskScheduler" class.

    I'm currently using SI 2.0.0M5.

    Here is the application XML (an edited version):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	xmlns:si="http://www.springframework.org/schema/integration"
    	xmlns:si-xml="http://www.springframework.org/schema/integration/xml"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:task="http://www.springframework.org/schema/task"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
    			http://www.springframework.org/schema/beans/spring-beans.xsd
    			http://www.springframework.org/schema/integration
    			http://www.springframework.org/schema/integration/spring-integration.xsd
    			http://www.springframework.org/schema/integration/xml
    			http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd
    			http://www.springframework.org/schema/context 
    			http://www.springframework.org/schema/context/spring-context.xsd
    			http://www.springframework.org/schema/task 
    			http://www.springframework.org/schema/task/spring-task.xsd">
    
    	<!-- Setup -->
    	<context:mbean-server />
    	<context:mbean-export registration="replaceExisting" server="mbeanServer" />
    	<context:component-scan base-package="...." />
    		
    	<bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" />
    	<bean id="appContextManager" class="....AppContextManager" />
    	
    
            <bean id="taskScheduler" class="org.springframework.integration.scheduling.SimpleTaskScheduler">
                  <constructor-arg ref="taskExecutor" />
           </bean>
           <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
              <property name="corePoolSize" value="3" />
              <property name="daemon" value="true" />
              <property name="keepAliveSeconds" value="60" />
              <property name="maxPoolSize" value="10" />
              <property name="queueCapacity" value="8" />
              <property name="rejectedExecutionHandler">
                  <bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy" />
              </property>
              <property name="threadNamePrefix" value="tx.node" />
              <property name="waitForTasksToCompleteOnShutdown" value="true" />
          </bean>	
         
    </beans>
    The error log is as following:

    Code:
    Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.integration.scheduling.SimpleTaskScheduler] for bean with name 'taskScheduler' defined in file [...\contexts\node-spring-context-main.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.integration.scheduling.SimpleTaskScheduler
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1235)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1304)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:870)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:556)
    	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.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
    	at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
    	at com.sita.typex.taxi.node.TaxiNodeMain.main(TaxiNodeMain.java:20)
    Caused by: java.lang.ClassNotFoundException: org.springframework.integration.scheduling.SimpleTaskScheduler
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    	at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
    	at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1256)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1227)
    	... 9 more

  2. #2
    Join Date
    Jun 2010
    Location
    Paris
    Posts
    106

    Default

    I haven't tried using schedulers yet, so I won't tell you whether this is the best solution doing it.
    However, I can tell you two things:

    1. You shouldn't have to provide the class of the task scheduler. I believe if you don't provide it, it will use the default implementation. I haven't checked though so I may be wrong... You'll tell me

    2. SI simply doesn't have such a class... Maybe "any more". Chances are that the implementations of schedulers were moved to Spring core with a different package and the documentation hasn't been updated yet.


    As far as I can see, there are three implementations of TaskScheduler, all three of them in Spring Core.

    • org.springframework.scheduling.concurrent.Concurre ntTaskScheduler
    • org.springframework.scheduling.concurrent.ThreadPo olTaskScheduler
    • org.springframework.scheduling.concurrent.TimerMan agerTaskScheduler


    Check the javadoc to know which one would suit best your needs. I believe the ThreadPoolTaskScheduler is the default implementation.
    Last edited by plecesne; Sep 13th, 2010 at 03:23 AM.

  3. #3
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    SimpleTaskScheduler was removed as we now rely on scheduling support provided by Spring 3.0 via <task:...> namespace. See: http://static.springsource.org/sprin...cheduling.html

  4. #4
    Join Date
    Jul 2009
    Location
    Charlotte, NC
    Posts
    131

    Default

    use something like this:
    <channel id="myChannel">
    <dispatcher task-executor="camThreadPoolTaskExecutor" failover="false" />
    </channel>

    <task:executor id="camThreadPoolTaskExecutor" pool-size="15-25"
    queue-capacity="100" rejection-policy="DISCARD_OLDEST" keep-alive="15" />
    Oleg, I have a question from this: do you have any suggestion about how to optimize the values for different params defined in the task executor?

  5. #5
    Join Date
    Jan 2010
    Posts
    124

    Default

    GPS: For task executor "camThreadPoolTaskExecutor" pool-size of 15-25, how many messageHandler EndPoints you need to define to consume messages from channel "myChannel"?
    Thanks
    sri

    Quote Originally Posted by GPS View Post
    use something like this:

    Oleg, I have a question from this: do you have any suggestion about how to optimize the values for different params defined in the task executor?

  6. #6
    Join Date
    Jul 2009
    Location
    Charlotte, NC
    Posts
    131

    Default

    I just have one message handler endpoint, consuming the messages coming on mychannel.
    myChannel is actually a wiretap on around 10-15 different direct channels in spring context, and I need to convert and persist their contents in DB, asynchronously behind the scenes.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •