调用类org.glassfish.ejb.startup.EjbApplication start方法时出现异常

时间:2014-08-28 08:44:38

标签: java-ee glassfish

我正在尝试在应用程序部署时启动作业调度程序。我正在使用石英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){}
    }
}

谢谢,我将非常感谢你们的帮助

1 个答案:

答案 0 :(得分:0)

您需要下载SLF4J并将最新的jar文件放入类路径