Results 1 to 10 of 10

Thread: WebSphere Scheduling with Spring and CommonJ - example

  1. #1
    Join Date
    Jan 2008
    Posts
    4

    Default WebSphere Scheduling with Spring and CommonJ - example

    I've written down an example of how we've used the CommonJ Spring integration to set up simple scheduling on WebSphere. There doesn't seem to be very much information about this, so I thought it might be useful for others

    The article is posted here:
    http://open.bekk.no/boss/spring-sche...-in-websphere/

    Feel free to make comments/suggestions here or on the article page.
    Last edited by eivindw; Jan 22nd, 2013 at 02:17 PM.

  2. #2
    Join Date
    Nov 2006
    Posts
    7

    Default Will it work in a clustered Websphere environment?

    Greetings,
    and thanks for the nice article.

    Without doing alot of research into this, do you know of any issues using commonJ in a clustered Websphere environment? We currently use Quartz to trigger jobs on the fly (i.e. they are not scheduled) to handle lengthy web requests that we poll with Ajax.

    Thanks again!

  3. #3
    Join Date
    Jan 2008
    Posts
    4

    Default

    Quote Originally Posted by geo View Post
    Without doing alot of research into this, do you know of any issues using commonJ in a clustered Websphere environment? We currently use Quartz to trigger jobs on the fly (i.e. they are not scheduled) to handle lengthy web requests that we poll with Ajax.
    I've only used it on a single-server environment. Not sure what possibilities you have when setting up WorkManagers in a clustered environment, and how they would behave. Of course you can use it on each server separately, but if they support some sort of failover or similar I don't know. Do post information here if you find more information

    Note that the article has been updated to reflect the fact that Quartz can also be used with the CommonJ WorkManager.

  4. #4
    Join Date
    Feb 2008
    Posts
    6

    Default TimerManager and WorkManager with Spring under Websphere - IllegalArgumentException

    Quote Originally Posted by eivindw View Post
    I've only used it on a single-server environment. Not sure what possibilities you have when setting up WorkManagers in a clustered environment, and how they would behave. Of course you can use it on each server separately, but if they support some sort of failover or similar I don't know. Do post information here if you find more information

    Note that the article has been updated to reflect the fact that Quartz can also be used with the CommonJ WorkManager.
    I was able to get the TimerManager and WorkManager with Spring running under Websphere 6.1.

    However in my batch runnable job, I need to access both TimerManager and WorkManager as the job needs to cancel or resume the timer when a piece of work is completed. I am able to access WorkManager in the job by injecting it into the bean as follows inthe spring config file:

    <bean id="testRunnable"class="org.frb.ny.mg.nacs.schedul er.jobs.SampleRunnable" >

    <property name="taskManager" ref="taskExecutor" /></bean>

    However I am not able to do the same for the timerManager when I add the following in the config file:

    <bean id="testRunnable"

    class="org.frb.ny.mg.nacs.scheduler.jobs.SampleRun nable" >

    <property name="taskManager" ref="taskExecutor" /><property name="dateTimerManager" ref="timerFactory" /></bean>

    I get the following error:

    Error 500: javax.faces.FacesException: javax.faces.el.EvaluationException: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'testRunnable' defined in ServletContext resource [/WEB-INF/resources/scheduler-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.ibm.ws.asynchbeans.timer.TimerManagerImpl] to required type [org.frb.ny.mg.nacs.scheduler.timer.DateTimerManage rFactoryBean] for property 'dateTimerManager'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.ibm.ws.asynchbeans.timer.TimerManagerImpl] to required type [org.frb.ny.mg.nacs.scheduler.timer.DateTimerManage rFactoryBean] for property 'dateTimerManager': no matching editors or conversion strategy found.

    Not sure why the asyncbeans package from ibm is invoked, maybe the commonJ api's call it internally. Alternately, if there is a way to retrieve the application context in workerManager or the runnable job, it may be possible to retrieve the timerManager bean and then invoke - cancel the timer - in the job.

    Any help /suggestions immediately would be greatly appreciated.

  5. #5
    Join Date
    Feb 2008
    Posts
    15

    Default

    Quote Originally Posted by eivindw View Post
    I've written down an example of how we've used the CommonJ Spring integration to set up simple scheduling on WebSphere. There doesn't seem to be very much information about this, so I thought it might be useful for others

    The article is posted here:
    http://boss.bekk.no/display/BOSS/Spr...g+in+WebSphere

    Feel free to make comments/suggestions here or on the article page.
    First of all thank you for that wonderful article. It has saved me countless hours.

    1. I was able to successfully integrated quartz and WorkManager into my application. For those who are interested, below is my spring beans file:

    HTML Code:
    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    		<property name="triggers">
    			<list>
    				<ref bean="cronReportTrigger" />
    			</list>
    		</property>
    		<property name="taskExecutor" ref="taskExecutor"></property>
    	</bean>
    
    	
    	<bean id="cronReportTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean" lazy-init="default" autowire="default" dependency-check="default">
    		<property name="jobDetail">
    		  <ref bean="sampleJobDetail" /> 
    		</property>
    		<property name="cronExpression">
    		  <value>1 * * * * ?</value> 
    		</property>
    	</bean>
    	
    	<bean id="sampleJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" lazy-init="default" autowire="default" dependency-check="default">
    		<property name="targetObject">
    			<ref bean="sampleJob" /> 
    		</property>
    		<property name="targetMethod">
    			<value>doJob</value> 
    		</property>
    	</bean>
    	
    	<bean id="sampleJob" class="ca.pro.jmx.SampleJob" lazy-init="default" autowire="default" dependency-check="default" />
    		
    	<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
    		<property name="workManagerName" value="wm/default"/>
    		<property name="resourceRef" value="false"/>
    	</bean>
    2. I would like to use a TimerManager but here is where I am having some difficulties. I used your sample code and setup my spring beans xml file as:

    HTML Code:
    <bean id="sampleBatchRunnable" class="ca.pro.jmx.SampleBatchRunnable"/>
    	
    <bean id="batchListener" class="ca.pro.jmx.ScheduledDateTimerListener">
          - Run at next  -
          <property name="timeStr" value="13:45"/>
          - Run at interval -
          <property name="period" value="60000"/>
          <property name="fixedRate" value="true"/>
          <property name="runnable" ref="sampleBatchRunnable"/>
    </bean>	
    
    	
    <bean id="timerFactory" class="ca.pro.jmx.DateTimerManagerFactoryBean">
    	<property name="timerManagerName" value="java:comp/env/tm/default"/>
    	<property name="resourceRef" value="false"/>
        <property name="scheduledDateTimerListeners">
             <list>
                <ref bean="batchListener"/>
             </list>
          </property>
       </bean>
    To my web.xml file I added:

    HTML Code:
    <resource-ref>
       <res-ref-name>tm/default</res-ref-name>
       <res-type>commonj.timers.TimerManager</res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Unshareable</res-sharing-scope>
     </resource-ref>
    When I deploy my application using the WebSphere application console, it prompts me to choose the TimerManager, but when I click on the browse button, the 'Available Resources' list is empty. When I click on the configured TimerManagers, I can see that there are many 'tm/default' TimerManagers configured (at different scopes). Then why does the available resources list show up blank.

    My configuration in web.xml file for a datasource is similar, but when I deploy my application, the available datasources are correctly shown in the Available Resources screen.

    Any ideas on what am I doing wrong with the TimerManager?

    Your help is much appreciated!

  6. #6
    Join Date
    Jul 2009
    Posts
    1

    Default

    What version of WebSphere are you using?

    I had the same problem with 6.1.0.19 (works with 6.1.0.25)

    It was able to work around it by just entering the JNDI name instead of browsing for it.

  7. #7

    Default

    Quote Originally Posted by eivindw View Post
    I've written down an example of how we've used the CommonJ Spring integration to set up simple scheduling on WebSphere. There doesn't seem to be very much information about this, so I thought it might be useful for others

    The article is posted here:
    http://boss.bekk.no/display/BOSS/Spr...g+in+WebSphere

    Feel free to make comments/suggestions here or on the article page.
    I was searching the Internet for articles on using IBM WebSphere Timer Manager and its integration with Spring. In this context I have found this
    http://forum.springsource.org/showthread.php?t=48631 and http://www.springsource.org/node/589 however the links are broken and I am unable to reach to your article.

    Could you please help me in getting me to your article and similar information on the subject I am searching for ...

  8. #8
    Join Date
    Jan 2008
    Posts
    4

    Default

    Sorry. We have switched around on our old servers, and this reference got lost. The article should be back now in a restored version: http://open.bekk.no/boss/spring-sche...-in-websphere/
    Last edited by eivindw; Jan 22nd, 2013 at 02:17 PM.

  9. #9

    Default

    Quote Originally Posted by eivindw View Post
    Sorry. We have switched around on our old servers, and this reference got lost. The article should be back now in a restored version: http://boss.bekk.no/boss/spring-sche...-in-websphere/
    Hi,

    I am not able to access http://boss.bekk.no/boss/spring-sche...-in-websphere/. Could you please update the correct link?

    Thanks in advance

  10. #10
    Join Date
    Jan 2008
    Posts
    4

    Default

    Seems the boss-domain is not working anymore. The direct link that works is now:
    http://open.bekk.no/boss/spring-sche...-in-websphere/

    I have updated the links further up in the thread as well..

Posting Permissions

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