我正在尝试在应用程序部署时启动作业调度程序。我正在使用石英api包含所有必需的jar文件,但我得到java.lang.NoClassDefFoundError
。这是异常的服务器日志消息:
SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton Cam2JobSchedular
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:656)
at....more
Caused by: java.lang.Exception: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:209)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)....
这是我试图在部署应用程序时运行的简单代码:
@Singleton
@Startup
public class Cam2JobSchedular
{
private static final Logger logger=Logger.getLogger(Cam2JobSchedular.class.getName());
@PostConstruct
public void init() {
//start the trigger
try
{
JobDetail job = JobBuilder.newJob(Cam2UpdateCentralDBJob.class)
.withIdentity("UpdateCam2Data").build();
// specify the running period of the job
Trigger trigger = TriggerBuilder.newTrigger()
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(30)
.repeatForever()).build();
//schedule the job
SchedulerFactory schFactory = new StdSchedulerFactory();
Scheduler sch = schFactory.getScheduler();
sch.start();
sch.scheduleJob(job, trigger);
logger.info("New Job started, Job ID: "+job.getKey().getGroup());
}
catch(Exception ex){}
}
}
谢谢,我将非常感谢你们的帮助