2013-10-02 35 views
0
@Schedule(minute = "*", hour = "*") 
    public void automaticTimeout() { 
     if (employeeDao == null) { 
      try { 
       InitialContext ctx = new InitialContext(); 
       employeeDao = (EmployeeDAO) ctx.lookup("java:comp/env/EmployeeDAO"); 
      } catch (NamingException ex) { 
       Logger.logFatal("automaticTimeout: employeeDao null. Something must be wrong", ex); 
      } 
     } 
     employeeDao.timeoutHandler(); 
    } 

我遷移到Java EE應用程序到Java EE 7「持久性定時器沒有了目標的Java EE 7 Web Profile的項目允許」,但EJB計時器無法正常工作。 當我使用@Schedule註釋錯誤出現時, 我正在使用JDK 7和Glassfish4, 除此之外,我正在使用Glassfish4完整平臺,因此IDE警告我 「目標Java EE的項目中不允許持久性計時器7 Web Profile「 我在重複,100%確定我正在使用Glassfish4完全平臺。同時使用GF4完整的個人資料

2013-10-02T16:40:00.048+0300] [glassfish 4.0] [WARNING] [ejb.system_exception] [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=162 _ThreadName=__ejb-thread-pool5] [timeMillis: 1380721200048] [levelValue: 900] [[ 
    EJB5184:A system exception occurred during an invocation on EJB TimerSessionBean, method: public void com.timer.TimerSessionBean.automaticTimeout()]] 

[2013-10-02T16:40:00.048+0300] [glassfish 4.0] [WARNING] [] [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=162 _ThreadName=__ejb-thread-pool5] [timeMillis: 1380721200048] [levelValue: 900] [[ 

javax.ejb.EJBTransactionRolledbackException 
    at com.sun.ejb.containers.BaseContainer.mapLocal3xException(BaseContainer.java:2279) 
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2060) 
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979) 
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220) 
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88) 
    at com.sun.proxy.$Proxy1024.timeoutHandler(Unknown Source) 
    at com.timer.TimerSessionBean.automaticTimeout(TimerSessionBean.java:53) 
    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 org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081) 
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153) 
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695) 
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) 
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582) 
    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.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) 
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundTimeout(SystemInterceptorProxy.java:145) 
    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.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) 
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369) 
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667) 
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655) 
    at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:3993) 
    at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1199) 
    at com.sun.ejb.containers.EJBTimerService.access$000(EJBTimerService.java:89) 
    at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:1919) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:166) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 
    at java.lang.Thread.run(Thread.java:724) 
Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean 
    at com.sun.ejb.containers.EJBContainerTransactionManager.checkExceptionClientTx(EJBContainerTransactionManager.java:662) 
    at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:507) 
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475) 
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009) 
    ... 44 more 
Caused by: java.lang.NullPointerException 
    at com.db.dao.EmployeeDaoImpl.setOffline(PersonDaoImpl.java:232) 
    at com.db.dao.EmployeeDaoImpl.timeoutHandler(PersonDaoImpl.java:246) 
    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 org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081) 
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153) 
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695) 
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) 
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582) 
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46) 
    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.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) 
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140) 
    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.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) 
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369) 
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667) 
+0

什麼是服務器日誌說? –

+0

我添加了服務器日誌。 – Poyraz

回答

1

該警告是由於在Eclipse中的一些錯誤的設置,使得它相信你的服務器是Web配置文件。

縱觀嵌套堆棧轉儲我可以看到你@Timeout註釋的方法,其實是在執行,但會拋出一個空指針異常

Caused by: java.lang.NullPointerException 
    at com.db.dao.EmployeeDaoImpl.setOffline(PersonDaoImpl.java:232) 
    at com.db.dao.EmployeeDaoImpl.timeoutHandler(PersonDaoImpl.java:246) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
相關問題