3 Replies Latest reply on Aug 15, 2011 8:32 AM by deryaaltuntas

    Help with Quartz MBean Service under JBoss using JNDI?

    techskn

      I am calling scheduler from a Java Console application. JBoss is running on localhost.
      I am trying to use Quartz Scheduler that has been deployed as a Service under JBoss using the supplied MBean service.xml. In the JBoss logs, I can clearly see that Quartz service is created and an instance of scheduler was also created.
      Log: QuartzService(Quartz) created.


      As Quartz is the default JNDI name, I am using below code and my scheduler is always null. Any help is really appreciated.


      Code:

      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      InitialContext ctx = new InitialContext(env);
      Scheduler sched = (Scheduler) ctx.lookup("Quartz");

      at this point my sched is always null. i am unable to figure out whats wrong. The way i am using JNDI?? please advise...

        • 1. Re: Help with Quartz MBean Service under JBoss using JNDI?
          imargelatu

          I have the exact same problem. In a Jboss instance, the QuartzService is successfully created. Even more, existing Quartz jobs are being executed as expected.

          I want to be able to access the Quartz Scheduler from a console application. However the following code prints out 'null' :

          
           public static void main(String[] args) throws Exception {
           InitialContext iniCtx = getInitialContext();
           Scheduler scheduler = (Scheduler)iniCtx.lookup("Quartz");
          
           System.out.println(String.format("Scheduler : %s", scheduler));
           }
          
           public static InitialContext getInitialContext() throws Exception {
           Hashtable<String, String> props = getInitialContextProperties();
           return new InitialContext(props);
           }
          
           private static Hashtable<String, String> getInitialContextProperties() {
           Hashtable<String, String> props = new Hashtable<String, String>();
           props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
           props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
           props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
           return props;
           }
          
          


          There are no exceptions thrown, however the Scheduler object is null.

          Am I doing something wrong ?

          • 2. Re: Help with Quartz MBean Service under JBoss using JNDI?
            imargelatu

            OK, I found the answer ... the Scheduler class is not Serializable so retrieving it from outside the JBoss server hosting it will return only a null. The Quartz RMI support must be used instead.

            Here is the relevant URL (read the Javadoc lines) :

            http://fisheye5.cenqua.com/browse/quartz/src/jboss/org/quartz/ee/jmx/jboss/QuartzServiceMBean.java?r=1.6

            • 3. Re: Help with Quartz MBean Service under JBoss using JNDI?
              deryaaltuntas

              I have exactly same problem.I could not open link you sent