29
Окт
2015

Ошибка EJB Timer Service is not available. Timers for application with id 94774118947028992 will not be deleted

Я создал Stateless bean который имеет метод, обозначенный аннотацией @Schedule. Запускаю я бин с помощью сервлета. Код бина:

@Stateless
public class StockServerBean {
private String price=null;
private ArrayList<String> nasdaqSymbols = new ArrayList<String>();
private String chooseSymb;
public String getChooseSymb() {
    return chooseSymb;
}

public void setChooseSymb(String chooseSymb) {
    this.chooseSymb = chooseSymb;
}

public StockServerBean(){
    // Define some hard-coded NASDAQ symbols
    nasdaqSymbols.add("AAPL");
    nasdaqSymbols.add("MSFT");
    nasdaqSymbols.add("YHOO");
    nasdaqSymbols.add("AMZN");
    nasdaqSymbols.add("MOT");
}

@Schedule(second="*",minute="*",hour="18,00-22,00", dayOfWeek="Mon-Sun")
public void getQuote(){
    if(nasdaqSymbols.indexOf(chooseSymb.toUpperCase()) != -1) {
    // Generate a random price for valid symbols
    price = (new Double(Math.random()*100)).toString();
    }
    Session session = null;
    Connection conn = null;
    ConnectionFactory factory = null;
    try{
        Context jndiC = new InitialContext();
        factory = (ConnectionFactory)jndiC.lookup("MyTestConnectionFactory");
        Queue queue = (Queue)jndiC.lookup("MyJMSTestQueue");

        conn = factory.createConnection();
        conn.start();

        session = conn.createSession(false,Session.AUTO_ACKNOWLEDGE);

        MessageProducer sender = session.createProducer(queue); 
        TextMessage outM = session.createTextMessage(chooseSymb + " : " + price);
        sender.send(outM);
        sender.close();
        System.out.println("Succesfully placed a price of  "  + chooseSymb + " :"+ price);

    }catch(JMSException je){
        System.out.println("Error: " + je.getMessage());
    }catch(NamingException ne){
        System.out.println("Error: " + ne.getMessage());
        ne.printStackTrace();
    }finally{
        try{
            session.close();
            conn.close();

        }catch(Exception e){
            System.out.println("Can't close session/connection :" + e.getMessage());
        }

    }
}

}

Код сервлета:

@WebServlet("/ExecutionServlet")
public class ExecutionServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
 * @see HttpServlet#HttpServlet()
 */
public ExecutionServlet() {
    super();
    // TODO Auto-generated constructor stub
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    StockServerBean bean = new StockServerBean();
    bean.setChooseSymb("AAPL");
    bean.getQuote();
    PrintWriter out = response.getWriter();
    out.println("Sending price to the queue");

}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
}

}

В результате выдает ошибку: cannot Deploy Lesson32 deploy is failing=Error occurred during deployment: Exception while loading the app : EJB Timer Service is not available. Please see server.log for more details.

Полный код ошибки:

     [2015-10-29T21:53:23.581+0200] [glassfish 4.1] [SEVERE] [NCLS-CORE-00026]             [javax.enterprise.system.core] [tid: _ThreadID=47 _ThreadName=admin-listener(4)]    [timeMillis: 1446148403581] [levelValue: 1000] [[
   Exception during lifecycle processing
   java.lang.RuntimeException: EJB Timer Service is not available
at   com.sun.ejb.containers.BaseContainer.startApplication(BaseContainer.java:4009)
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:500)
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:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
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.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)

]]

Следуя указаниям : http://docs.oracle.com/cd/E18930_01/html/821-2434/ggrvi.html#glhnl я создал в glassfish свойство com.sun.ejb.timer.ReadDBBeforeTimeout=false. И ошибка осталась та же.. Помогите пожалуйста, кто сталкивался с такой проблемой.

Источник: https://ru.stackoverflow.com/questions/462409/%D0%9E%D1%88%D0%B8%D0%B1%D0%BA%D0%B0-ejb-timer-service-is-not-available-timers-for-application-with-id-947741

Share

Тебе может это понравится...