1

Velocity Engine 在我的项目中用于发送有关用户操作和作业触发的邮件。

虽然通过用户操作发送的邮件非常好,但作业发送的邮件有时会收到内容为空的邮件。这是非常随机的,我似乎无法将其与任何原因联系起来。发生这种情况时没有错误日志。(在添加 NullLogChute 属性之前,我确实收到了一次 Velocity 无法初始化错误。我被告知这将解决异常,但它所做的只是阻止异常出现在日志中。邮件仍然有空内容) 请帮忙!

之前的例外:

ERROR 2012-07-29 05:00:00,219 com.myProject.util.VelocityUtil - Velocity could not be initialized!
java.lang.RuntimeException: Velocity could not be initialized!
..
..
Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.AvalonLogChute with the current runtime configuration.

我在我的 spring servlet xml 中设置速度配置属性:

<bean id="velocityUtil" class="com.myProject.util.VelocityUtil" >
 <property name="velocityConfiguration">
  <props> 
   <prop key="resource.loader">class</prop>
   <prop key="class.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop>
   <prop key="runtime.log.logsystem.class">org.apache.velocity.runtime.log.NullLogChute</prop> 
  </props>
 </property>

在 spring servlet 中设置的 Quartz 属性:

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="applicationContextSchedulerContextKey"><value>applicationContext</value></property>
     <property name="quartzProperties">
        <props> 
            <prop key="org.quartz.scheduler.instanceName">Quartz</prop> 
            <prop key="org.quartz.scheduler.instanceId">AUTO</prop> 
            <prop key="org.quartz.scheduler.rmi.export">false</prop> 
            <prop key="org.quartz.scheduler.rmi.proxy">false</prop> 
            <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop> 
            <prop key="org.quartz.threadPool.threadCount">5</prop> 
            <prop key="org.quartz.threadPool.threadPriority">1</prop> 
            <prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop> 
            <prop key="org.quartz.jobStore.tablePrefix">EES.QRTZ_</prop> 
            <prop key="org.quartz.jobStore.isClustered">true</prop> 
            <prop key="org.quartz.jobStore.misfireThreshold">60000</prop> 
            <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.MSSQLDelegate</prop>
        </props>
      </property>
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="triggers">
    <list>
        <ref bean="Mod1CronTrigger" />
        <ref bean="Mod2CronTrigger" />
        <ref bean="Mod3CronTrigger" />
        <ref bean="Mod4CronTrigger" /> 
        <ref bean="Mod5CronTrigger" /> 
        <ref bean="Mod6CronTrigger" />
    </list>
    </property>
</bean>

<list>定义jobDetail 和CronExpression中的每个触发器。例如,

<bean id="Mod1CronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="Mod1Job"/>
    <property name="cronExpression" value="0 30 3 1/1 * ? *"/>
</bean>

<bean name="Mod1Job" class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="com.myProject.jobs.Mod1Job" />
    <property name="name" value="Mod1Job" />
</bean>
4

0 回答 0