 
 (defn ^{:internal true} stop-job
   "Stops (unschedules) a job, removing it from the scheduler."
-  [^BaseScheduledJob job]
+  [job]
   (if-not (.isShutdown (.getScheduler job))
     (.stop job)))
 
 ;; we don't currently register an mbean for each job, since we can't
 ;; yet easily unregister the mbean
 ;; ignore reflection here for now, since we don't even use it yet
-(defn register-job-mbean [name job]
+(try-defn (import org.immutant.jobs.as.JobsServices) register-job-mbean [name job]
   (.installMBean
    (job-schedulizer)
    (.append JobsServices/JOBS

;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

(ns immutant.jobs.internal
  (:use [immutant.utilities :only [app-name]])
  (:require [immutant.registry :as registry]
            [clojure.tools.logging :as log])
  (:import [org.immutant.jobs ClojureJob JobScheduler JobSchedulizer ScheduledJobMBean]
           [org.immutant.jobs.as JobsServices]
           [org.projectodd.polyglot.jobs BaseScheduledJob]))

(defn ^{:private true} #^JobSchedulizer job-schedulizer  []
  (registry/fetch "job-schedulizer"))

(defn ^{:internal true} create-scheduler

  "Waits for the scheduler to start before invoking f"
  ([scheduler f]
     (wait-for-scheduler scheduler f 30))
  ([scheduler f attempts]
     (cond
      (.isStarted scheduler) (f)
      (< attempts 0)         (throw (IllegalStateException.
