[英]Error in lookup property in quartz 2.0.2 with Oracle DB
我正在從石英版本 1.6.0 遷移到 2.0.2。 它似乎工作正常,因為我可以看到數據在服務器啟動時插入到我們的 oracle 數據庫中的石英表中,並且石英調度程序設置也成功。
但是,當作業嘗試第一次運行時,我遇到以下錯誤,即作業無法通過PropertyLoader
從 DB 加載緩存屬性,這些PropertyLoader
是在服務器啟動時設置的(Jboss 5.1)。
下面我也得到一個java.lang.IncompatibleClassChangeError
如堆棧跟蹤中提到的:
Error in the lookupProperty() java.lang.NullPointerException
01/23 07:40:00,142 -STDERR- java.lang.NullPointerException
01/23 07:40:00,142 -STDERR- at com.qd.qhadmin.common.business.PropertyLoader.lookupProperty(PropertyLoader.java:36)
01/23 07:40:00,142 -STDERR- at com.qd.qehadmin.common.scheduler.MessageloadJob.execute(MessageloadJob.java:27)
01/23 07:40:00,142 -STDERR- at org.quartz.core.JobRunShell.run(JobRunShell.java:206)
01/23 07:40:00,142 -STDERR- at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:548)
01/23 07:40:00,142 -STDERR- java.lang.NumberFormatException: null
01/23 07:40:00,143 -STDERR- at java.lang.Integer.parseInt(Integer.java:417)
01/23 07:40:00,143 -STDERR- at java.lang.Integer.<init>(Integer.java:660)
01/23 07:40:00,143 -STDERR- at com.qd.qehadmin.common.scheduler.MessageDownloadJob.execute(MessageDownloadJob.java:27)
01/23 07:40:00,143 -STDERR- at org.quartz.core.JobRunShell.run(JobRunShell.java:206)
01/23 07:40:00,143 -STDERR- at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:548)
01/23 07:42:00,075 -org.quartz.core.JobRunShell- Job QH_QUARTZ.Mre match Job threw an unhandled Exception:
java.lang.IncompatibleClassChangeError: Found interface org.quartz.JobExecutionContext, but class was expected
at com.qd.qehadmin.common.scheduler.MREMatchJob.execute(MREMatchJob.java:129)
at org.quartz.core.JobRunShell.run(JobRunShell.java:206)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:548)
01/23 07:42:00,078 -org.quartz.core.ErrorLogger- Job (QH_QUARTZ.Mre match Job threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.IncompatibleClassChangeError: Found interface org.quartz.JobExecutionContext, but class was expected]
at org.quartz.core.JobRunShell.run(JobRunShell.java:217)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:548)
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.quartz.JobExecutionContext, but class was expected
at com.qd.qehadmin.common.scheduler.MREMatchJob.execute(MREMatchJob.java:129)
at org.quartz.core.JobRunShell.run(JobRunShell.java:206)
-------Property loader code as below-----------
package com.qd.qhadmin.common.business;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import com.qd.qhadmin.common.database.PropertiesDAO;
public class PropertyLoader {
private static Map<String,String> properties = null;
private static PropertyLoader loader = null;
private static Map<String,String> appXMLVersions = null;
public static void init(){
System.out.println("* * * * * * * * * * * * PropertyLoader START");
loader = new PropertyLoader();
try {
loader.loadAppProp();
loader.displayProp(properties, "Property");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("* * * * * * * * * * * * PropertyLoader FINISH");
}
public static String lookupProperty(String propName) {
/*
* Find property value by name
*/
System.out.println("property Name is:::::"+propName);
String propertyValue = null;
try {
if (properties.containsKey(propName.trim())) {
propertyValue = (String) properties.get(propName.trim());
System.out.println("property value is::::"+propertyValue);
} else {
System.out.println("PropertyLoader.lookupProperty() can't find this property: " + propName.trim());
}
} catch (Exception f) {
System.out.println("Error in the lookupProperty() " + f);
f.printStackTrace();
}
return propertyValue;
}
private void displayProp(Map hm, String refDataType) throws Exception {
TreeMap tm = new TreeMap(hm);
Set keyset = tm.keySet();
Iterator it = keyset.iterator();
String name = "", value = "";
while (it.hasNext()) {
name = ((String) it.next()).toUpperCase();
if (name.contains("PASSWORD") || name.contains("SECKEY")){
value = "********";
}else if (name.contains("APPER_AP")){
value = (String) hm.get(name);
value = value.substring(0, 10) + "*************";
}
else{
value = (String) hm.get(name);
}
System.out.println(refDataType + " " + name + " = " + value);
}
}
private void loadAppProp() throws Exception {
java.net.InetAddress in = java.net.InetAddress.getLocalHost();
String hostname = in.getHostName();
properties = getProperties(hostname);
}
private Map<String,String> getProperties(String groupName) {
Map<String,String> properties = new HashMap<String,String>();
PropertiesDAO dao = new PropertiesDAO();
properties = dao.getProperties();
return properties;
}
public static void main(String[] args) {
PropertyLoader loader = new PropertyLoader();
}
}
--------Mre match code----------------
public void execute(JobExecutionContext ctx) throws JobExecutionException
{
LogFile.MRE_MATCH_JOB.logInfo("***MRE Match Job starting*** ", this.getClass().getName());
try{
//Scheduler scheduler = new StdSchedulerFactory().getScheduler();
LogFile.MRE_MATCH_JOB.logInfo("MMRE jobs size : "+ctx.getScheduler().getCurrentlyExecutingJobs().size(), this.getClass().getName());
initWrapperClient();
startTime=System.currentTimeMillis();
mmreMatch();
endTime=System.currentTimeMillis();
LogFile.MRE_MATCH_JOB.logInfo("***MRE Match job ends*** Loadtest: "+Constants.loadTest+" in time: "+(endTime-startTime)/1000 + "secs", this.getClass().getName());
}catch(Exception e){
e.printStackTrace();
LogFile.MRE_MATCH_JOB.logError("***MRE Match Job Error*** " +e.getStackTrace(), this.getClass().getName());
}
}
問題是您使用 Quartz 1.6 編譯代碼,其中JobExecutionContext
是一個類。 但是在運行時,你有 Quartz 2+,其中JobExecutionContext
實際上是一個接口。
如果你可以用 Quartz 2.0 編譯你的代碼,這個問題就會消失。
如果您正在構建一個可以同時使用 Quartz 1.6 和 2.0 的模塊,您可能需要使用適配器解耦和隱藏 Quartz。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.