Servlet background process on tomcat 4.0.2

i have 1 servlet which will run a thread, background process, whenever the init() on that servlet called. i tried on tomcat 3.3a and tomcat 3.2.3, and both tomcat will run my servlet's background process, will run the thread. but, when i run the servlet using tomcat 4, tomcat 4 will run the init(), but when it do not start the thread. what happen?... i used the same code, servlet, on tomcat 3.2.3, 3.3a and 4....
can anyone explain it to me?.....

my code look like this:
public class Discover extends HttpServlet implements Runnable
Thread t = null;
boolean running = false;
public void init()
t = new Thread(this);
t.start();
System.out.println("thread start");
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("discover=" + running);
public void run()
running = true;
System.out.println("thread running...");
* do some stuff here....
running = false;
System.out.println("thread stopped...");
i tried this servlet on tomcat 3.2.3 and 3.3a and the thread run. i can see the 'thread start', 'thread running' and 'thread stopped' on the tomcat console. but, when i use tomcat 4, i can only see 'thread start' on the console, which show that the run() is not execute...... y?... please help me.......

Similar Messages

  • Using ServletContextListener for background process in tomcat, problems?

    Hi, I am building a web app using mojarra 1.2, hibernate 3.2, mysql 5 and tomcat 6. Currently, there's a need to run a background process every hour to:
    1) query the database
    2) process information
    3) send emails to (big) list of individuals when matched
    4) update database
    5) must happen during business hour
    For now, my approach to this problem is to hook a Timer object inside a class implements ServletContextListener. So that every hour during business hour will process the steps above when Tomcat started until someone shut down shut down Tomcat or when it crash (hopefully that won't happen).
    I read a few articles, they claimed this is not a good approach because in a managed environment, background thread like this won't be in the scope of the container.
    Due to certain reasons, we can't deploy this part as a separate daemon (e.g: jsvc) yet. We'll need to wait for few other things to occur before can we deploy a full daemon services.
    The question for this post is: What are some of the potential problems we will be dealing with when running background thread like this in tomcat? What are some of the things we'll need to watch out for before real problems arise (e.g size of db connection, # of concurrent process, etc) what are some other pitfalls other experienced when deploying background thread in tomcat?
    We hope this solution will be able to handle what needs to be done until our daemon service is ready.
    Thank you for your opinions

    You can try this.. Which gives more grip... in making threads etc..
    Here is a class with a method that sets up a ScheduledExecutorService to beep every ten seconds for an hour:
    import static java.util.concurrent.TimeUnit.*;
    class BeeperControl {
    private final ScheduledExecutorService scheduler =
    Executors.newScheduledThreadPool(1);
    public void beepForAnHour() {
    final Runnable beeper = new Runnable() {
    public void run() { System.out.println("beep"); }
    final ScheduledFuture<?> beeperHandle =
    scheduler.scheduleAtFixedRate(beeper, 10, 10, SECONDS);
    scheduler.schedule(new Runnable() {
    public void run() { beeperHandle.cancel(true); }
    }, 60 * 60, SECONDS);
    }

  • How to deploy an app with servlet and background processing

    i have a servlet with background processing. it has to run 24 hours a day.
    but i have problem with shutdown (after 1-2 hours without user action). [9iAS 9.0.3.0, windows 2000]
    i created for application seperate OC4J (in the EM) and i deployed it there. first time as war file, later as ear file (because there is possible to re-deploy only ear file).
    but it seems that the servlets are not designated to run as a uninterruptible task.
    the question is: how to deploy such (servlet + uninterruptible background processing) application in the 9iAS?
    a) everything in the OC4J (then how to disable shutdown?)
    b) servlet in the OC4J. where (and how) to install the rest of application?
    b1) servlet in the OC4J + rmi/soap/... + standalone server?
    what is the standard in the oracle world :) ?
    thanks

    Better to post your topic in the iPad in the Enterprise community.
    This is the, "Using Mac App Store" forum and for the most part for troubleshooting the App Store.

  • How to run a background process in a J2EE App ?

    Hi guys,
    Here is the requirement which totally stumped me.
    " The web app should have a feature like a background process or something like cron jobs.. which keeps on running in the background and at a particular time each day calls a method". User intervention is not an option.
    Now had this been a stand alone app .. I could have done this using Threads.. but i cant possibly use threads in a J2EE app. Any pointers.. how I can go about realizing this
    Thanks for your replies.
    Cheers!

    You could take the approach that SoulTech mentioned and spawn a new thread from the Servlet's init method. To have the servlet invoke this method with no intervention, you would need to set the following parameter in your servlet definition in your web.xml:
    <servlet>
      <servlet-name>MyStartupServlet</servlet-name>
      <servlet-class>com.my.company.MyStartupServlet</servlet-class>
      *<load-on-startup>1</load-on-startup>*
    </servlet>When you deploy your application, the servlet will be loaded, and its init method will be called.
    If your application is running in a servlet container, I believe you are allowed (by the specification) to spawn your own threads, but you should do so carefully. Since you're writing a scheduler and not some kind of worker threads that are messing with your database, I think you should be okay. Still, just to keep it clean you should add any clean-up logic you may need to your servlet's destroy method. I know that in an EJB container, spawning your own threads can definitely be a problem and the container makes no guarantees that they will function correctly. The J2SE Timer class could be used if you're not using EJB, but the Timer class doesn't have support for J2EE - that's at least part of what led to the introduction of the timer beans in J2EE 1.4. If you're already using EJB, especially EJB 3.0, then the timer service provides a convenient built-in mechanism to do exactly what you want.
    There are always multiple ways to solve any problem...
    Edited by: proflux on May 15, 2008 1:04 PM

  • How can I let my servlet to process Chinese Character as an input?

    How can I let my servlet to process Chinese Character as an input to my simple database which is an Excel file. I have tried before and all my input values become question marks.
    Please give me some advise, thx!

    input chinese?����������
    that may result from the tomcat or other web server

  • Weblogic 8.1 SP2 + Struts + Internal Servlet Session Process Error Found!

    Hi,
              I have developed a struts 1.1 based webapplication which runs fine on
              weblogic 7 (for one year in production), tomcat 4.1,5 and others but
              refuses to function in weblogic 8.1 sp2!
              This is the stacktrace I get when I try to call an action via the browser:
              java.lang.IllegalStateException: Internal Servlet Session Process Error
              Found!
                   at
                   weblogic.servlet.internal.session.SessionData.checkProcess(SessionData.java:1148)
                   at
                   weblogic.servlet.internal.session.SessionData.setAttribute(SessionData.java:501)
                   at
                   org.apache.struts.action.RequestProcessor.processLocale(RequestProcessor.java:638)
                   at
                   org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230)
                   at
                   org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420)
                   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:502)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
                   weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
                   at
                   weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
                   at
                   weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
                   at
                   weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
                   at
                   weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
                   at
                   weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
                   at
                   weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
                   at
                   weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197) at
                   weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
              Just out of curiosity I deployed the struts-examples webapplication from
              the apache jakarta struts distribution and it also fails to run with the
              same error!
              Can anybody help me out with this one? Does anybody experience the same
              thing?
              regards,
              oliver
              p.s. I will also post this message on the struts user list.
              

    Hi,
              I have developed a struts 1.1 based webapplication which runs fine on
              weblogic 7 (for one year in production), tomcat 4.1,5 and others but
              refuses to function in weblogic 8.1 sp2!
              This is the stacktrace I get when I try to call an action via the browser:
              java.lang.IllegalStateException: Internal Servlet Session Process Error
              Found!
                   at
                   weblogic.servlet.internal.session.SessionData.checkProcess(SessionData.java:1148)
                   at
                   weblogic.servlet.internal.session.SessionData.setAttribute(SessionData.java:501)
                   at
                   org.apache.struts.action.RequestProcessor.processLocale(RequestProcessor.java:638)
                   at
                   org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230)
                   at
                   org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420)
                   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:502)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at
                   weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
                   at
                   weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
                   at
                   weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
                   at
                   weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
                   at
                   weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
                   at
                   weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
                   at
                   weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
                   at
                   weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197) at
                   weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
              Just out of curiosity I deployed the struts-examples webapplication from
              the apache jakarta struts distribution and it also fails to run with the
              same error!
              Can anybody help me out with this one? Does anybody experience the same
              thing?
              regards,
              oliver
              p.s. I will also post this message on the struts user list.
              

  • How to run background process with web application

    Hi,
    I have a web application , a servlet. I would like to have a background process that collecting data for my servlet.
    How can I achieve this? can someone point me to a tutorial or example?
    Also, would it be possible to share an object between the background process and myservlet?
    Thanks,

    Thanks for the idea.
    I had the background process running. :)
    But I'm still do not understand this part to share an object such as Java Map (<id,myobject>), what do you mean by "task a property of my ServletContextListener" ?
    BalusC wrote:
    If you make the task a property of your ServletContextListener implementation and put the implementation in the application scope, then you can access it from any servlet.Do you mind explain to me a bit more I'm still fairly new with this or maybe if you know an example.
    Here's my code snippet so far. How can I share myList to MyServlet?
    public class MonitorTimer extends TimerTask
           private Map<String, Channel> myList;
         @Override
         public void run()
              System.out.println("Monitor Timer times up");
              //Clear the map before fill with the new data
              if(myList!= null)
                   myList.clear();
              loadConfig();
            private void getData()
               //fill myList with data
    public class MyContextListener implements ServletContextListener
         @Override
         public void contextDestroyed(ServletContextEvent arg0)
              // TODO Auto-generated method stub
         @Override
         public void contextInitialized(ServletContextEvent arg0)
              System.out.println("Context Initialized");
              Timer timer = new Timer();
              //Run MonitorTimer every 2 minutes
              timer.scheduleAtFixedRate(new MonitorTimer(), 10*1000,2*60*1000);
    public class MyServlet extends HttpServlet implements Servlet
         @Override
         public void destroy()
              // TODO Auto-generated method stub
              super.destroy();
         @Override
         protected void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException
    }Thank you so much for your help,
    Edited by: geek.shrek on Nov 4, 2009 1:50 PM

  • Launch a background process

    Hi!
    In my web application when a certain button is pressed i need to launch a invisible background process while i continue using the application
    What do you recommend me to do this?
    Thanks!
    T.

    Couple of ways you can do this.
    1 - Have the background process implement the interface Runnable. Start a new thread for this process. You can keep a reference to it in session if you want to monitor it.
    2 - In a J2EE environment, send a JMS message to trigger a process.
    Either of these will let control return to your servlet immediately, and you can return a response of "job started, check back later" to the user.

  • GUI_DOWNLOAD and background processing

    Hello,
    I have created a process which creates a file. this process uses GUI_DOWNLOAD to put the file on the users C drive or other directory on our network. The user wants to run this process in background and the program is returning a 6  (error unknown) from the GUI_DOWNLOAD FM. I was looking on SDN and found out the GUI_DOWNLOAD only works in foreground. You have to use OPEN and CLOSE DATASET statements to process in background. I am thinking about putting a button to denote foreground/background processing and using the appropriate statements to process the file. I will then have to get the file from the app server to a place will the user can get access to it.
    <b>first question</b> - is there a FM to do a FTP from the app server to a directory on our network for the user to access?
    <b>second question</b> - is this the right approach or is there something else that I should be doing.
    thanks in advance for your help

    Hi,
    Yes, your right, GUI_DOWNLOAD wil not work in background mode, you need to place the file in Application server, here.
    See the below link for a FTP program, use the proper commands(i do not know whether downloading the file is possible through the commands)
    http://www.sap-img.com/ab003.htm
    or else, write a small program which downloads the data from the application server, but it should run in the foreground
    Regards
    Sudheer

  • The request could not be submitted for background processing.

    Post Author: Chriss
    CA Forum: Administration
    It's an BOE XI SR2, on Win2k3 server, with a print cluster with two print spools, handling 3000+ printers. I discovered this error to be intermittent and only on one of the spools. It turned out that the only common factor was an HP4250 print driver. I backed all the 4250s down to 4200 drivers and the intermitent error ("Error in File. The request could not be submitted for background processing.") went from about 100 a day to zero. The other spool had a different version of the HP4250 driver and would on rare occassion cause this error, "Error in File ... Page header or footer longer than a page." but never the background processing error.
    For reference, when I got this error in XI R1, this was the solution for 'the error with one name and many causes':The error "The request could not be submitted for background processing" can be related to a corrupt or wrong versioned crpe32.dll in the Crystal bin folder. Renaming to crpe32.dll_bak and using the repair command in the the "Add/Remove Programs" tool in the "Control Panel" will reinstall the correct dll. Then restart the Crystal services.

    Post Author: krishna.moorthi
    CA Forum: Administration
    For Crystal reports :
    Error : "The request could not be submitted for background processing"
    I think,this was not related to a corrupt or wrong versioned crpe32.dll.
    but the below mentioned is one of the reason for getting this error.
    I got the error when the main report(crystalreports10) having more than 2 subreports not assigned proper tables for the subreports.
    Example: (this code raise the abone mentioned error.)
    rpt.SetDataSource(Exdataset);
    rpt.Subreports&#91;"subreportname1"&#93;.SetDataSource(Exdataset); // Exdatatset.Tables&#91;1&#93;
    rpt.Subreports&#91;"subreportname2"&#93;.SetDataSource(Exdataset);// Exdatatset.Tables&#91;2&#93;

  • How to Create Excel File in Background processing with different colors

    HI All
    I am trying to create Excel file in background & send it to user through e-mail, this i could acheive using fucntion module SO_DOCUMENT_SEND_API1, but here my requirement is i want to put different colors to columns of excel & this should happen in Background processing,
    Initially i completed above requirement by using HTML type of document with attachment type 'ALI'  & formatted output using write statement & used colors, after that i took this o/p using save_list function module & then table compress...etc.
    but i don't know how to achieve same if we need o/p in excel as size of object of excel file is less than that of HTML
    I am thankfull to everybody who will help me.
    Regards
    Lokesh

    Lokesh,
    Iam also trying to populate my text file with colors as an attachment . If you know this please let me know.

  • Data of alv report in  excel file in background processing using open datas

    Hi Experts,
    I have developed report for purchase register . if i execute this report in background process i am not able to get the downloaded file in excel and output is also not coming properly, columns are going to overlap.
    i used open dataset  read dataset and close dataset but still problem is not solved. so if anyone have code with this and also which will have concatenate statement in the code send it.
    Regards,
    Rahul

    Hi Rahul,
    Ur code shud be like below:
    DATA : l_filename2 TYPE string,
                v_extn.
        SPLIT p_filename AT '.xls' INTO l_filename2  v_extn.
        CONCATENATE l_filename2  'downloaded'  INTO l_filename2  SEPARATED BY '_'.
        CONCATENATE l_filename2  'txt'   INTO l_filename2 SEPARATED BY '.'.
        OPEN DATASET l_filename2 IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
        IF sy-subrc <> 0.
          MESSAGE e499(sy) WITH text-e02.
        ENDIF.
        LOOP AT it_order_number INTO wa_order_number.
          TRANSFER wa_order_number TO l_filename2.
        ENDLOOP.
        CLOSE DATASET l_filename2.
    Now, go to tcode AL11 and check it in the Application server itself.
    Hope this helps,
    Regards,
    Arnab.

  • When running the workflow background process for drop shipment order, sale order line's status gets automtically closed instead of awaiting shipping

    Hello friends,
    I am created a drop shipment order with all the setups done . now i have booked the sale order as source type external. but when i run the workflow background process , after completing the report when i check the sale order line status it changes to "closed" instead of "awaiting shipping".
    Plz guide me if i have missed something in the setups.
    thanks,
    Sachin

    Hi Sachin,
    pls check the below notes from MOS
    Drop Ship Sales Order Cycle In Order Management (Doc ID 749139.1)
    Vision Demo - How To Create A Drop Ship Sales Order/Purchase Order (Doc ID 1060343.1)
    Thanks
    -Arif.

  • Crystal Reports VS 2008 "The request could not be submitted for background processing"

    Hi,
    I am going to try to explain this issue the best I can. Please let me know if you need any other information or have any ideas as I have exhausted my resources. We have an ASP.NET application that has highly formatted crystal reports in them that the users can export as PDFs. All reports export without a problem when the application is run off of our desktops. The reports use a sql server authenticated user, executing stored procedures, and each subreport is linked by the main parameter. We are using Visual Studio 2008 version 3.5 SP1 with Crystal Reports Basic for Visual Studio 2008 on Windows 7 Enterprise SP1. We have designed the reports in Crystal Reports XI Release 2 (11.5.12.1838) and imported them into the ASP.NET application. When trying to export the reports as PDFs from the development or production servers, we get the error message below for some, not all, reports:
    System.Runtime.InteropServices.COMException (0x800002AD):  Error in File C:\Windows\TEMP\KeyAccountProfile {9FA5C095-77A2-425D-AC6B-8BB66B435336}.rpt: The request could not be submitted for background processing.     at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)     at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
    We have cleared the temp directory on the servers before exporting and are still receiving the error. We have installed Crystal Reports Basic Runtime for Visual Studio (10.5.2.0) on both servers. I have identified the underlying issue to one stored procedure/subreport that is causing the report to fail. The weird thing is, when we change the connection to point to development, the stored procedure/subreport runs fine for the report that generates an error when run from production, and the data is the exact same. I have tried rebuilding the subreport but the error still appears even though it runs fine for other reports.
    I have been through the document below, and othe similar issues in the forums, but still have not found a resolution. I was trying to use the "modules" application put since this is an ASP.NET application I am unsure of which executable I should be looking at.
    http://www.sdn.sap.com/irj/boc/go/portal/prtroot/docs/library/uuid/50a6f5e8-8164-2b10-7ca4-b5089df76b33?QuickLink=index&overridelayout=true&36837934524320
    Thanks in advance for your assistance,
    Brad Hood
    06-26-14
    OK.. I did some more investigating on this today. I have found out when I move the sub report that generates the error under another sub report, the sub report in question runs without issue. But when I try and move the sub report that produces the error above any other sub report, the error still generates. Can this get any weirder.... FYI.. there is a total of ten sub reports on this report.

    Hi Brad
    I'm not sure that Modules would show us anything in this case, so let's try a few other things:
    1) Make sure you are using SP 1 for Crystal Reports Basic Runtime for Visual Studio:
    Crystal Reports for VS 2005 and VS 2008 Updates & Runtime Downloads
    2) Seeing as this works on dev, this may be some db inconsistency so enabling the report option "Verify on 1st Print" will be a good idea.
    3) Double check the database client and make sure the same client is used on dev and deployed systems. Actually I take back my Modules negative as this is where it may prove useful. Once you have the Modules logs, look at who is loading the crpe32.dll, then look at that process and see the client dlls.
    4) Check the printer driver; see if there are any updates. Try a different printer driver.
    Ten subreports is not too bad, though not that good either as you are loading the report engine with at minimum 11 simultaneous reports (each subreport is considered to be a report). If a subreport is in a details section and the details section returns a 100 records, you are running 100 + 1 reports. This may lead to memory issues, which may lead to the error.
    If I was a betting man, I'd put most of my money on the printer driver (based on your last addition to your post). What ever money I had left would go to some database issue (be it actual data or client related).
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Background process taking very long time to complete.

    Dear All,
    Platform: HP UX
    Version: 12.0.6
    While time of shutting down the instance below background process taking very long time to complete.
    what is below mention process? can i kill it? total 3 process i am getting while finding ps -ef|grep applpre(applepre is apps instance's owner)
    applpre/apps/tech_st/10.1.3/appsutil/jdk/bin/IA64N/java -DCLIENT_PROCESSID=5457 -server -Xmx384m -XX:+UseSerialGC -Dor
    Thanks in Advance,
    Sandeep.

    Sandeep,
    Please see (Note: 567551.1 - Configuring various JVM tuning parameters for Oracle E-Business suite 11i and R12).
    You can safely kill those processes from the OS.
    Thanks,
    Hussein

Maybe you are looking for