KK

          Kim-'s-Blog.Object-Everything.I'm POJO.

          .紀(jì)-錄.爲(wèi)了忘卻的記憶..真的勇士,要敢于直面遇到的問(wèn)題,敢于正視繁雜的原碼......在實(shí)踐中積累!

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            74 Posts :: 1 Stories :: 70 Comments :: 0 Trackbacks
          與 數(shù)據(jù)庫(kù) db 相關(guān)操作有兩種:
          1.從DB中讀cronExpression
          2.Job持久化到數(shù)據(jù)庫(kù)
          對(duì)于1:
          Quartz 在Spring中動(dòng)態(tài)設(shè)置cronExpression
          參考 小刀的blog
          http://www.aygfsteel.com/xiaodaoxiaodao/articles/103437.html 

          通過(guò)DB加載cronException

          一個(gè)類是可以的
          2個(gè)類會(huì)出問(wèn)題

           <bean id="test2" class="cn.edu.hust.mes.service.quartz.Test">  
             
          <property name="scheduler" ref="schedulerFactoryBean"/>         
             
          </bean>  
               
             
          <bean id="test" class="Test">  
             
          <property name="scheduler" ref="schedulerFactoryBean"/>  
             
          </bean>  
               
             
          <bean name="schedulerFactoryBean"  
                       
          class="org.springframework.scheduling.quartz.SchedulerFactoryBean">  
                    
          <property name="triggers">  
                         
          <list>  
                           
          <ref bean="cronTriggerForPLCRead"/>  
                           
          <ref bean="cronTrigger"/>  
                        
          </list>  
                   
          </property>  
             
                   
          <property name="configLocation" value="classpath:quartz.properties"/>  
              
          </bean> 


          Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'schedulerFactoryBean': FactoryBean which is currently in creation returned null from getObject

          如果寫了攔截器的化 還會(huì)報(bào)這個(gè)錯(cuò) :

          Error creating bean with name 'test2': Bean with name 'test2' has been injected into other beans [schedulerJobDetailForPLCRead] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.


          對(duì)于2:
          MethodInvokingJobDetailFactoryBean 不能持久化
          必須用JobDetailBean 需繼承QuartzJobBean  不夠pojo
          使用MethodInvokingJobDetailFactoryBean的化會(huì)報(bào):
          org.quartz.JobPersistenceException: Couldn't store job: Unable to serialize JobDataMap for insertion into database because the value of property 'methodInvoker' is not serializable: org.springframework.scheduling.quartz.MethodInvoki ngJobDetailFactoryBean [See nested exception: java.io.NotSerializableException: Unable to serialize JobDataMap for insertion into database because the value of property
          API上說(shuō)了
          There's a note in the JavaDoc, I'd presume this might be your problem.
          JobDetails created via this FactoryBean are not serializable and thus not suitable for persistent job stores. You need to implement your own Quartz Job as a thin wrapper for each case where you want a persistent job to delegate to a specific service method.
          http://www.springframework.org/docs/api/org/springframework/scheduling/quartz/MethodInvokingJobDetailFactoryBean.html
          用MethodInvokingJobDetailFactoryBean不可持久化 除非加個(gè)thin wrapper
          但查不到任何資料
          但愿spring后續(xù)版本有好的方案 現(xiàn)在還是老老實(shí)實(shí)的用JobDetailBean吧

          另:
          不可用于web action action 用了session等作用域...
          Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request? If you are actually operating within a web request and still receive this message,your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
          posted on 2009-03-19 22:19 Kim' 閱讀(4256) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          jj
          主站蜘蛛池模板: 满城县| 漳州市| 三亚市| 疏勒县| 吴川市| 贵南县| 云南省| 河曲县| 长泰县| 本溪市| 盖州市| 平昌县| 洱源县| 文成县| 辽中县| 南丹县| 乐陵市| 海城市| 莒南县| 松江区| 南充市| 昔阳县| 治县。| 白河县| 黄石市| 三台县| 灯塔市| 泰和县| 乐业县| 托里县| 深州市| 霍林郭勒市| 大同市| 旅游| 城市| 黔西县| 南溪县| 襄樊市| 红原县| 江都市| 屏边|