Cron job run on time but failure to execute ofy().load().type()… query any configure i require in appengine.xml

会有一股神秘感。 提交于 2019-12-12 02:39:15

问题


I working on project using java on GAE. I used cron job for some remainders. I set time for cron job once a day. GAE run cron job at time but my cron job Implementation class execute on stating 4 5 lines only after 5 lines there is ofy code hat is not executed why? bellow is my code

My appengine-web.xml:-

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">    
<application>evadev014</application>
version>9</version>
<threadsafe>true</threadsafe>
<instance-class>F4_1G</instance-class>

<!-- Configure serving/caching of GWT files -->
<static-files>
<include path="**" />
 <!-- The following line requires App Engine 1.3.2 SDK -->
<include path="**.nocache.*" expiration="0s" />
<include path="**.cache.*" expiration="365d" />
<exclude path="**.gwt.rpc" />
</static-files>

<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>

</appengine-web-app>

My Cron.xml :-

<cron>
<url>/slick_erp/cronPhysicalInventoryCronJob</url>
<description>Implemented for due stock. </description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronCustomerService</url>
<description>Implemented for due services of customer.</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronContractRenewal</url>
<description>Implemented for due contract renewal. </description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronCustomerARPayment</url>
<description>Implemented for due payments of customer. Accounts Receivable.</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronLead</url>
<description>Implemented for due leads of customer.</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronDeliveryNote</url>
<description>Implemented for pending delivery notes of customer.</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronCustomerAPPayment</url>
<description>Implemented for due payments of customer. Accounts Payable.</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronCustomerAPInvoice</url>
<description>Implemented for due invoices of customer. Accounts Payable</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronCustomerARInvoice</url>
<description>Implemented for due invoices of customer. Accounts Receivable</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronSalesQuotation</url>
<description>Implemented for due sales quotations of customers.</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronServiceQuotation</url>
<description>Implemented for due service quotation of customers.</description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronGoodsReceiptNote</url>
<description>Implemented for due GRNs. </description>
<schedule>every day 04:00</schedule>
</cron>

<cron>
<url>/slick_erp/cronApproval</url>
<description>Implemented for due approvals. </description>
<schedule>every day 04:00</schedule>
</cron>

My web.xml :-

<servlet>
        <servlet-name>CustomerServiceCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.CustomerServiceCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>CustomerServiceCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronCustomerService</url-pattern>
    </servlet-mapping>      

    <servlet>
        <servlet-name>DeliveryNoteCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.DeliveryNoteCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>DeliveryNoteCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronDeliveryNote</url-pattern>
    </servlet-mapping>  

    <servlet>
        <servlet-name>CustomerPaymentAPCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.CustomerPaymentAPCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>CustomerPaymentAPCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronCustomerAPPayment</url-pattern>
    </servlet-mapping>  


    <servlet>
        <servlet-name>CustomerPaymentARCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.CustomerPaymentARCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>CustomerPaymentARCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronCustomerARPayment</url-pattern>
    </servlet-mapping>  


    <servlet>
        <servlet-name>InvoiceAPCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.InvoiceAPCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>InvoiceAPCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronCustomerAPInvoice</url-pattern>
    </servlet-mapping>  

    <servlet>
        <servlet-name>InvoiceARCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.InvoiceARCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>InvoiceARCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronCustomerARInvoice</url-pattern>
    </servlet-mapping>  

    <servlet>
        <servlet-name>SalesQuotationCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.SalesQuotationCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>SalesQuotationCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronSalesQuotation</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>ServiceQuotationCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.ServiceQuotationCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ServiceQuotationCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronServiceQuotation</url-pattern>
    </servlet-mapping>


    <servlet>
        <servlet-name>GoodsRecievedNoteCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.GoodsReceiptNoteCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>GoodsRecievedNoteCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronGoodsReceiptNote</url-pattern>
    </servlet-mapping>



    <servlet>
        <servlet-name>LeadCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.LeadCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>LeadCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronLead</url-pattern>
    </servlet-mapping>


    <servlet>
        <servlet-name>ContractRenewalCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.ContractRenewalCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ContractRenewalCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronContractRenewal</url-pattern>
    </servlet-mapping>


    <servlet>
        <servlet-name>PhysicalInventoryCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.PhysicalInventoryCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>PhysicalInventoryCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronPhysicalInventoryCronJob</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>ApprovalCronJobImpl</servlet-name>
        <servlet-class>com.slicktechnologies.server.cronjobimpl.ApprovalCronJobImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ApprovalCronJobImpl</servlet-name>
        <url-pattern>/slick_erp/cronApproval</url-pattern>
    </servlet-mapping>

My logger i geting like this :-

Before OFY code its executing when ofy().load.... lines not executing why?

This is one of my cron job code:-

import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.simplesoftwares.client.library.ReturnFromServer;
import com.simplesoftwares.client.library.libservice.GenricService;
import com.simplesoftwares.client.library.libservice.GenricServiceAsync;
import com.slicktechnologies.client.utility.AppConstants;
import com.slicktechnologies.server.Email;
import com.slicktechnologies.server.utility.DateUtility;
import com.slicktechnologies.shared.common.businessprocesslayer.Customer;
import com.slicktechnologies.shared.common.businessunitlayer.Company;
import com.slicktechnologies.shared.common.helperlayer.SmsConfiguration;
import com.slicktechnologies.shared.common.helperlayer.SmsTemplate;
import com.slicktechnologies.shared.common.numbergenerator.ProcessName;
import com.slicktechnologies.shared.common.processconfiguration.ProcessConfiguration;
import com.slicktechnologies.shared.common.salesprocess.CustomerPayment;
import com.slicktechnologies.shared.common.smshistorydetails.SmsHistory;
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.resource.factory.MessageFactory;
import com.twilio.sdk.resource.factory.SmsFactory;
import com.twilio.sdk.resource.instance.Account;

import static com.googlecode.objectify.ObjectifyService.ofy;

public class CustomerPaymentARCronJobImpl extends HttpServlet {

    /**
     * 
     */
    private static final long serialVersionUID = -1352789385430511259L;


    private SimpleDateFormat fmt = new SimpleDateFormat("dd-MMM-yyyy");
    private SimpleDateFormat fmtPaymentDate = new SimpleDateFormat("dd/MM/yyyy");
     Logger logger = Logger.getLogger("NameOfYourLogger");



        public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {

                custPaymentARlist();
        }

        private void custPaymentARlist() {





            Email cronEmail = new Email();

            Date today=DateUtility.getDateWithTimeZone("IST", new Date());
            fmt.setTimeZone(TimeZone.getTimeZone("IST"));
            fmtPaymentDate.setTimeZone(TimeZone.getTimeZone("IST"));;
            /**
             *   Adding 1 day extra to date
             */

            logger.log(Level.SEVERE,"Date Before Adding "+today);
            DateFormat dateFormat=new SimpleDateFormat("dd/MM/yyyy");
            Calendar cal=Calendar.getInstance();
            cal.setTime(today);
            cal.add(Calendar.DATE, 0);

            Date dateForFilter=null;

            try {
                dateForFilter=dateFormat.parse(dateFormat.format(cal.getTime()));
                cal.set(Calendar.HOUR_OF_DAY,23);
                cal.set(Calendar.MINUTE,59);
                cal.set(Calendar.SECOND,59);
                cal.set(Calendar.MILLISECOND,999);
                dateForFilter=cal.getTime();
            } catch (ParseException e) {
                e.printStackTrace();
            }

            logger.log(Level.SEVERE,"Date After setting the Time"+dateForFilter);

            /************************************* End *********************************/


     try{

         logger.log(Level.SEVERE,"In Payment AR List"); 
        logger.log(Level.SEVERE,"Date After Adding One Date"+dateForFilter);


    /********************************Adding status in the list ***********************/

         ArrayList<String> obj = new ArrayList<String>();
         obj.add("Created");
         obj.add("Requested");



    /******************************Converting todayDate to String format*****************/

         Date todaysDate = new Date();
         SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
         String todayDateString = df.format(todaysDate);
         System.out.println("String in dd/MM/yyyy format is: " + todayDateString);


 /********************************Adding Companies in the list ***********************/

    List<Company> compEntity = ofy().load().type(Company.class).list();
    if(compEntity.size()>0){

        logger.log(Level.SEVERE,"If compEntity size > 0");
        logger.log(Level.SEVERE,"Size of compEntity"+compEntity.size());


        for(int i=0;i<compEntity.size();i++){

            Company c=compEntity.get(i);
            logger.log(Level.SEVERE,"In the for loop");
            logger.log(Level.SEVERE,"Company Name="+c);
            logger.log(Level.SEVERE,"The value of i is:" +i);
            logger.log(Level.SEVERE,"Date After Adding One Date"+dateForFilter);

I am not getting this logger and below this line logger :- logger.log(Level.SEVERE,"Size of compEntity"+compEntity.size()); as i showed in my program

any help?

来源:https://stackoverflow.com/questions/33951806/cron-job-run-on-time-but-failure-to-execute-ofy-load-type-query-any-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!