I am using dotcms osgi job plugin to schedule jobs.Running a single job is working fine.But when I create multiple cron jobs using the same job class,I get the below error,
Can anyone advice/comment here. Below is the code.The first scheduling of job works fine but error arises when second job is scheduled.
Error while starting bundle: file:/C:/D%20Drive/core-3.1/core-3.1/build/war/dotcms/WEB-INF/felix/load/VaultFetchFiles-Plugin-1.0.jar: com.dotcms.repackage.org.osgi.framework.BundleException: Activator start error in bundle vaultSharedDriveJobOSGI [8]
.
com.dotcms.repackage.org.osgi.framework.BundleException: Activator start error in bundle vaultSharedDriveJobOSGI [8].
at com.dotcms.repackage.org.apache.felix.framework.Felix.activateBundle(Felix.java:2196)
at com.dotcms.repackage.org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
at com.dotcms.repackage.org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1175)
at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1153)
at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:458)
at com.dotcms.repackage.org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:263)
Caused by: java.lang.NullPointerException
at com.dotmarketing.osgi.UrlOsgiClassLoader.reload(UrlOsgiClassLoader.java:212)
at com.dotmarketing.osgi.UrlOsgiClassLoader.reload(UrlOsgiClassLoader.java:97)
at com.dotmarketing.osgi.GenericBundleActivator.injectContext(GenericBundleActivator.java:282)
at com.dotmarketing.osgi.GenericBundleActivator.injectContext(GenericBundleActivator.java:250)
at com.dotmarketing.osgi.GenericBundleActivator.scheduleQuartzJob(GenericBundleActivator.java:431)
at com.mhf.vault.fetchfiles.activator.FetchFilesJobActivator.start(FetchFilesJobActivator.java:69)
at com.dotcms.repackage.org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
at com.dotcms.repackage.org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)
... 6 more
public class FetchFilesJobActivator extends GenericBundleActivator {
private static final String TRUE = "true";
public final static String JOB_NAME = "SharedDrive Job";
public final static String JOB_CLASS = "FetchFilesJob";
public final static String JOB_GROUP = "User Jobs";
private static final Logger logger = Logger.getLogger(FetchFilesJobActivator.class);
public void start ( BundleContext context ) throws Exception {
logger.info("***************** Inside Activator for FetchFilesJob framework **************************"); //The initialization/publishing fails now in 2.5.6 .Hopefully will be resolved when we upgrade to 3.* dotCMS
initializeServices( context );
//publishBundleServices( context );
String configurationFile = VaultFetchFileConstants.FETCHFILES_CONFIG;
Configuration configuration = new Configuration();
configuration = GetFilesJobUtil.readSetConfiguration(GetFilesJobUtil.fetchConfigFromFolder(configurationFile),Configuration.class);
Map<String, Object> params = new HashMap<String, Object>();
if(configuration != null
&& configuration.getSharedDrives() != null
&& configuration.getSharedDrives().getDrive() != null
&& !(configuration.getSharedDrives().getDrive().isEmpty()))
{
for(Drive drive: configuration.getSharedDrives().getDrive())
{
if(drive.getCriteria() != null && drive.getCriteria().getCriteriaValues() != null)
{
for(CriteriaValues cValues:drive.getCriteria().getCriteriaValues())
{
if (cValues.getConfigured().equalsIgnoreCase(TRUE))
{
params.put("param1", cValues.getcID().trim());
params.put("param2", drive.getGroupName().trim());
params.put("param3", cValues.getDirectoryPath().trim());
params.put("param4", cValues.getFromDate().trim());
params.put("param5", cValues.getToDate().trim());
String job_name = JOB_NAME+cValues.getcID().trim();
CronScheduledTask cronScheduledTask = new CronScheduledTask(job_name, JOB_GROUP, job_name, JOB_CLASS,
new Date(), null, CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW,
params,cValues.getCronExpression());
//Schedule our custom job
scheduleQuartzJob( cronScheduledTask );// Multiple job set up calling the same class but different job names
}
}
}
}
}
Thanks