Glassfish计划(计时器)例外

时间:2014-04-01 12:50:15

标签: java java-ee glassfish ejb

我正在尝试在Glassfish 4和java EE7上重复this tutorial。 所以我用Netbeans中的maven创建了简单的WebApp。

我创建了简单的类:

import java.util.Date;
import javax.ejb.Schedule;
import javax.ejb.Stateless;

@Stateless
public class NewClass {

    @Schedule(minute = "*/1", hour = "*",persistent = false) 
    public void anyMethod() {
        System.out.println("hello "+new Date());
    }
}

但是当我将app下载到服务器时,我得到了这个例外:

Info:   EJB5181:Portable JNDI names for EJB NewClass: [java:global/WebApplication1/NewClass, java:global/WebApplication1/NewClass!NewClass]
Severe:   Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
java.lang.RuntimeException: EJB Timer Service is not available
    at com.sun.ejb.containers.BaseContainer.startApplication(BaseContainer.java:3951)
    at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:163)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:744)

Severe:   Exception during lifecycle processing
java.lang.RuntimeException: EJB Timer Service is not available
    at com.sun.ejb.containers.BaseContainer.startApplication(BaseContainer.java:3951)
......

Severe:   Exception while loading the app
Severe:   Undeployment failed for context /test
Warning:   EJB Timer Service is not available. Timers for application with id 91511565780975616 will not be deleted
Severe:   Exception while loading the app : EJB Timer Service is not available

为什么EJB Timer Service不可用?   我该如何启用它? :)

3 个答案:

答案 0 :(得分:10)

我也有同样的问题,但@ wumbrath的回答并不奏效。如果是这种情况 - 请先尝试该答案 - 删除以下文件:

applications/ejb-timer-service-app
generated/ejb/ejb-timer-service-app
generated/jsp/ejb-timer-service-app
generated/policy/ejb-timer-service-app
generated/ejb-timer-service-app
lib/databases/ejbtimer

当然,重启服务器。

(来源:http://www.cnblogs.com/endtel/p/5437765.html

答案 1 :(得分:2)

如果您使用的是嵌入式玻璃鱼,可能会被禁用,您应该尝试下载独立的玻璃鱼并再试一次。

关于配置,您可以验证glassfish管理控制台中的设置,通常可以在http://localhost:4848处找到:

以下设置是相关的:

  • 配置 - > server-config - > EJB容器 - > EJB计时器服务选项卡
  • 资源 - > JDBC - > JDBC连接池 - > __TimerPool(这里你也可以通过Ping按钮测试连接)

答案 2 :(得分:0)

转到安装glassfish:

mv glassfish/glassfish-4.1.1/glassfish/domains/domain1
rm -rf applications/ejb-timer-service-app/
rm -rf generated/ejb/ejb-timer-service-app/
rm -rf generated/jsp/ejb-timer-service-app/
rm -rf generated/policy/ejb-timer-service-app/
rm -rf generated/ejb-timer-service-app 
rm -rf lib/databases/ejbtimer/