Announcement Announcement Module
Collapse
No announcement yet.
CronTrigger property loading problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CronTrigger property loading problem

    Hello everyone!

    I tried to configure CronTrigger's cronExpression property from a properties file, but still could not manage to do it.

    here is what I tried, but everytime at the applicationContextLoading phase I ama getting exception about it.

    Code:
    <bean id="propertyConfigurerTest" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="location">
                <value>classpath:quartz.properties</value>
            </property>
    </bean>
    ...
    <bean id="dailyReportNotificationTriggerTest" class="org.springframework.scheduling.quartz.CronTriggerBean">
    		<property name="jobDetail" ref="dailyReportNotificationJobTest" />
    		<property name="cronExpression" value="${quartz.cron.expression}"/>                    
    		<!--<property name="cronExpression" value="* */1 * * * ?" />        -->
    </bean>
    ...
    this is a maven project and every property file is in resources directory.
    but here is the error I got
    Code:
    Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dailyReportNotificationTriggerTest' defined in class path resource [applicationContext-reporter-test.xml]: Could not resolve placeholder 'quartz.cron.expression'
    	at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:268)
    	at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:553)
    	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:527)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362)
    	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
    	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:42)
    	at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:173)
    	at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:197)
    also here is the configuration of the Test class currently that I am trying to run
    Code:
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { "/applicationContext-test.xml" })
    public class NotificationServiceTest extends AbstractJUnit4SpringContextTests {...}
    Kind Regars, Melh.

  • #2
    Its probably not seeing the properties file in the classpath. Where is the properties file? You could try using the absolute path to see if it works.

    Comment

    Working...
    X