Announcement Announcement Module
Collapse
No announcement yet.
Spring Sheduler Stoped Working In My Web App Production Environment Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Sheduler Stoped Working In My Web App Production Environment

    Hi All,

    I am working with Web development using Spring 2.5. I have two scheduled task in my app. Once i deployed the app to prod Environment it was working fine initially. After some day it was stop working and it lead to restart our prod server. You guys have any idea why its happening. This is happened three of four times in our project.

    Thank you

    Jay.

  • #2
    You haven't really provided very much detail here. Are we talking about Spring Batch? Is there a stack trace? Can you post some of your code? Give details about the platform?

    Comment


    • #3
      Hey first of all thank you for the response.

      Basically its not the problem with the code i guess,

      anyways am putting the code here,

      code segment to load the properties,

      Code:
      public class HomePageHelper extends TimerTask
      {
      
      private void loadModifiedPageProperties()
          {
              PageConfiguration homePageConfiguration = m_pageService.getHomePageConfiguration();
              if (homePageConfiguration == null)
              {
                  m_log.info("Home page configuration does not exist or null.");
              }
              else
              {
                  if (homePageConfiguration.getLastModified().getTime() > m_homePageProperties.getLastModif().getTime())
                  {
                      m_homePageProperties.setLastModif(homePageConfiguration.getLastModified());
                      m_homePageProperties.getCache().removeAll();
                      m_log.info("Reloading home page properties of " + homePageConfiguration.getUrlFriendlyName());
                      m_homePageProperties.setConfigurationUniqueName(homePageConfiguration.getUrlFriendlyName());
                      m_homePageProperties.setConfigurationName(homePageConfiguration.getConfigurationName());
                      m_homePageProperties.loadProperties(homePageConfiguration.getInputStream(), homePageConfiguration.getPageType());
                  }
              }
      
              List<PageConfiguration> categoryPageConfigurationList = m_pageService.getCategoryPageConfiguration();
              if (categoryPageConfigurationList != null)
              {
                  // Removing unpublished configurations
                  Map<String, PageConfiguration> pageConfigurationMap = new HashMap<String, PageConfiguration>();
                  for (PageConfiguration pageConfiguration : categoryPageConfigurationList)
                  {
                      pageConfigurationMap.put(pageConfiguration.getUrlFriendlyName(), pageConfiguration);
                  }
                  Set<String> keys = m_categoryPagePropertiesMap.keySet();
                  for (String key : keys)
                  {
                      if (!pageConfigurationMap.containsKey(key))
                      {
                          m_categoryPagePropertiesMap.remove(key);
                          m_log.info("Removed unpublished category properties " + key);
                      }
                  }
                  Set<String> existConfiguration = m_configurationInfo.keySet();
                  for(String confName : existConfiguration)
                  {
                      if(!pageConfigurationMap.containsKey(confName))
                      {
                          if(!pageConfigurationMap.get(confName).isShowOnNav())
                          {
                              m_configurationInfo.remove(confName);
                              m_log.info("Removed unpublished link from the header." + confName);
                          }
                      }
                  }
                  for (PageConfiguration pageConfiguration : categoryPageConfigurationList)
                  {
                      if (pageConfiguration != null)
                      {
                          // Updating existing configurations
                          if (m_categoryPagePropertiesMap.containsKey(pageConfiguration.getUrlFriendlyName()))
                          {
                              HomePageProperties categoryPageProperty = m_categoryPagePropertiesMap.get(pageConfiguration.getUrlFriendlyName());
                              if (pageConfiguration.getLastModified().getTime() > categoryPageProperty.getLastModif().getTime())
                              {
                                  if(m_configurationInfo.containsKey(pageConfiguration.getUrlFriendlyName()) && !pageConfiguration.isShowOnNav())
                                  {
                                      m_configurationInfo.remove(pageConfiguration.getUrlFriendlyName());
                                  }
                                  if(m_configurationInfo.containsKey(pageConfiguration.getUrlFriendlyName()))
                                  {
                                      m_configurationInfo.get(pageConfiguration.getUrlFriendlyName()).setOrder(pageConfiguration.getOrder());
                                  }
                                  if(!m_configurationInfo.containsKey(pageConfiguration.getUrlFriendlyName()) && pageConfiguration.isShowOnNav())
                                  {
                                      createPageConfigurationInfo(pageConfiguration);
                                  }
                                  categoryPageProperty.setLastModif(pageConfiguration.getLastModified());
                                  categoryPageProperty.getCache().removeAll();
                                  categoryPageProperty.setConfigurationUniqueName(pageConfiguration.getUrlFriendlyName());
                                  categoryPageProperty.setConfigurationName(pageConfiguration.getConfigurationName());
                                  m_log.info("Reloading category page properties of " + pageConfiguration.getUrlFriendlyName());
                                  categoryPageProperty.loadProperties(pageConfiguration.getInputStream(), pageConfiguration.getPageType());
                              }
      
                          }
                          // Adding newly published configurations
                          if (!m_categoryPagePropertiesMap.containsKey(pageConfiguration.getUrlFriendlyName()))
                          {
                              if(pageConfiguration.isShowOnNav())
                                  createPageConfigurationInfo(pageConfiguration);
                              m_log.info("Addiing new category properties for " + pageConfiguration.getUrlFriendlyName());
                              HomePageProperties categoryPageProperty = new HomePageProperties(m_listService);
                              categoryPageProperty.setLastModif(pageConfiguration.getLastModified());
                              categoryPageProperty.setCache(m_cacheManager.getCache(m_props.getProperty("cache.html")));
                              categoryPageProperty.setConfigurationUniqueName(pageConfiguration.getUrlFriendlyName());
                              categoryPageProperty.setConfigurationName(pageConfiguration.getConfigurationName());
                              categoryPageProperty.loadProperties(pageConfiguration.getInputStream(), pageConfiguration.getPageType());
                              m_categoryPagePropertiesMap.put(pageConfiguration.getUrlFriendlyName(), categoryPageProperty);
                          }
                      }
                      else
                      {
                          m_log.info("Category page configuration does not exist or null.");
                      }
                  }
              }
              else
              {
                  m_categoryPagePropertiesMap.clear();
              }
          }
      
         
       public void run()
          {
              this.loadModifiedPageProperties();
          }
        
      
      }
      
      My applicationContect.xml
      
      <!-- ==============================   PAGE PROPERTIES RELOADER   ============================= -->
         
        <bean id="pagePropertiesDynamicLoader" class="com.xxxxxx.web.homepage.HomePageHelper" />
        
        <bean id="pagePropertiesScheduler" class="org.springframework.scheduling.timer.ScheduledTimerTask">
          <property name="timerTask" ref="pagePropertiesDynamicLoader" />
          <property name="delay" value="${xxxxxx.page.properties.load.delay}" />
          <property name="period" value="${xxxxxx.page.properties.load.period}" />
        </bean>
      
         <!-- ==============================   RANKER SCHEDULED TASKS   ============================= -->
         
        <bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
          <property name="scheduledTimerTasks">
            <list>
                      <ref bean="pagePropertiesScheduler" />
            </list>
          </property>
        </bean>

      This configuration exactly working fine, but I think if some thread related exception thrown somewhere else in the application the TimerTask stopping the execution.

      I last day i noticed that the TimerTask stopped executing after mysql thead pool exception thrown while db server not reachable.

      Anybody have any idea why the TimerTask stopping, if some other thread related exception thrown inside the app.


      Thanks,

      Jay
      Last edited by vijaymohanp; Dec 11th, 2009, 10:53 AM.

      Comment


      • #4
        First of all, please use CODE tags when posting code...

        Secondly, I don't see how the code you posted is germane to spring batch. You are just running a timer that is configured via spring.

        Basically its not the problem with the code i guess,
        Would you bet your next months pay on that? If not, then don't rule it out.

        FWIW, having used the JDK timer in the past, if your job ever throws an exception, the task will stop running..in fact the whole timer will die. You have to be very diligent about catching ANY throwables in your task and handling them...if you throw your exception to the timer, it will no longer run your task...or any other task.

        See here:

        http://bryanpendleton.blogspot.com/2...-handling.html

        In your task you are trapping NO exceptions

        Comment

        Working...
        X