Announcement Announcement Module
Collapse
No announcement yet.
Quartz in Spring meets Djava.endorsed.dirs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz in Spring meets Djava.endorsed.dirs

    I have created the following basic classes and an configuration file to illustrate the problem :

    The Java code :

    Code:
    public class RanchBean {
    	private String message;
    
    	public void setMessage(String message) {
    		this.message = message;
    	}
    
    	public void welcome() {
    		System.out.println("[JOBBEAN] " + message);
    	}
    }
    Code:
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.FileSystemXmlApplicationContext;
    
    
    public class RunQuartz {
    
    	public static void main(String args[])
    	{
    		ApplicationContext context = new FileSystemXmlApplicationContext("c:\\Quartz.xml");
    	}
    	
    }
    The configuration file :

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    	<bean id="methodInvokingJob"
    		class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    		<property name="targetObject" ref="welcomeBean" />
    		<property name="targetMethod" value="welcome" />
    	</bean>
    
    	<bean id="ranchTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
    		<property name="jobDetail" ref="methodInvokingJob" />
    		<property name="startDelay" value="0" />
    		<property name="repeatInterval" value="10000" />
    	</bean>
    
    	<bean name="welcomeBean" class="RanchBean">
    		<property name="message" value="Welcome at JavaRanch" />
    	</bean>
    
    	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    		<property name="triggers">
    			<list>
    				<ref bean="ranchTrigger" />
    			</list>
    		</property>
    	</bean>
    
    
    </beans>
    Running this in SpringSource Tool Suite everything is OK.
    Running the following command :
    java -cp C:\quartz.jar;C:\spring.jar;C:\commons-logging-1.1.jar;C:\quartz-all-1.6.5.jar RunQuartz

    With the two classes in the quartz.jar it stills works.

    However I don't like putting all the jars in the command so I changed to the following command:
    java -Djava.endorsed.dirs=C:\ RunQuartz

    Which creates the following stacktrace :
    Code:
    24-mrt-2009 19:00:28 org.springframework.core.CollectionFactory <clinit>
    INFO: JDK 1.4+ collections available
    24-mrt-2009 19:00:28 org.springframework.core.CollectionFactory <clinit>
    INFO: Commons Collections 3.x available
    24-mrt-2009 19:00:28 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from file [c:\Quartz.xml]
    24-mrt-2009 19:00:28 org.springframework.context.support.AbstractRefreshableApplicationContext refreshBeanFactory
    INFO: Bean factory for application context [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=33152054]: org.springframework.beans.factory.support.DefaultListableBeanFactory
     defining beans [methodInvokingJob,ranchTrigger,welcomeBean,org.springframework.scheduling.quartz.SchedulerFactoryBean]; root of BeanFactory hierarchy
    24-mrt-2009 19:00:28 org.springframework.context.support.AbstractApplicationContext refresh
    INFO: 4 beans defined in application context [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=33152054]
    24-mrt-2009 19:00:28 org.springframework.context.support.AbstractApplicationContext initMessageSource
    INFO: Unable to locate MessageSource with name 'messageSource': using default [[email protected]f2]
    24-mrt-2009 19:00:28 org.springframework.context.support.AbstractApplicationContext initApplicationEventMulticaster
    INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@1484a05]
    24-mrt-2009 19:00:28 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [methodInvokingJob,ranchTrigger,welcomeBean,org.springframework.sched
    uling.quartz.SchedulerFactoryBean]; root of BeanFactory hierarchy]
    24-mrt-2009 19:00:28 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
    INFO: Destroying singletons in {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [methodInvokingJob,ranchTrigger,welcomeBean,org.springframework.scheduling.quartz.Sc
    hedulerFactoryBean]; root of BeanFactory hierarchy}
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean' defined in file [c:\Quart
    z.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
    Caused by: java.lang.NullPointerException
            at org.quartz.impl.StdSchedulerFactory.initialize(StdSchedulerFactory.java:382)
            at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1361)
            at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler(SchedulerFactoryBean.java:668)
            at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:568)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1024)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:140)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
            at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:89)
            at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:74)
            at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:65)
            at RunQuartz.main(RunQuartz.java:9)

    Is their a way I can use the -Djava.endorsed.dirs an still have a running program?
Working...
X