0

To describe my question, I will demonstrate the purpose of my Maven Web Application. I am developing a booking service which allows people to book taxi. The booking services work well but my problem is the booking request from yesterday and previous days must be canceled by a background task (It may have another name but I do not know how to call it correctly, I apologize). This task have a function that scan the database each minute to check the status of the booking, if it expired, cancel it. I defined a class called Main.java and configure my web.xml file like this but there is no result in the system log.

My Main.java

package com.bvps.bacground;

public class Main {
    public static void main(String[] args){
        System.err.println("123123123123213");
    }
}

And the web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>bvps</display-name>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <listener>
        <listener-class>bvps.Main</listener-class>
    </listener>
    <servlet>
        <servlet-name>jersey-serlvet</servlet-name>
        <servlet-class>
            com.sun.jersey.spi.container.servlet.ServletContainer
        </servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>bvps.service</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/v1/*</url-pattern>
    </servlet-mapping>

</web-app>

Many thanks for reading this, please help me!

iamatsundere181
  • 1,401
  • 1
  • 16
  • 38
  • 1
    I think you are looking for scheduled tasks. Please look at this link it might help http://stackoverflow.com/questions/7814089/how-to-schedule-a-periodic-task-in-java – Badr Jun 20 '16 at 08:34
  • Thanks but the problem is I can not target this class run within the web app. – iamatsundere181 Jun 20 '16 at 10:36

0 Answers0