Sleeping 'watcher' servlet crashes JRUN

I have set up a servlet that runs a query once every 2 hours. I have made a while(true) loop that loops forever then executes the query then tells my thread that i created to sleep for 7200000 milliseconds. I tried using
Thread.currentThread.sleep(7200000) ;
and then also tried creating a new thread
Thread myThread = new Thread();
myThread.sleep(7200000);
(BTW: This is all in a method i call from the init method)
Either way if I invoke the servlet from a jsp it works fine but the jsp is always stuck working on getting a response. If I go into JRUN and set up the servlet to be preloaded when JRUN is started, it executes once then JRUN locks up. And when I try to view the site I see the "Could not connect to JRun Server" error. From this point on I have to complete hose the entire jrun instance and create a new jrun server instance. The JRUN instance cant be restarted, even rebooting doesnt work.
Is the servlet sleeping the jrun init thread itself? Im sorry Im new to threads.
Thanks for any help anyone can give me!

Is the servlet sleeping the jrun init thread itself?
Im sorry Im new to threads.Yes. This is exactly what is happening.
You need to spawn another thread, that does nothing but runs through your while ( true ) ... loop, sleeping for the required two hours every now and then.
Something like this:
class MySleepingThread implements Runnable
   public void run()
      while ( true )
          doTheStuffINeedToDoEveryTwoHours();
          try
             Thread.sleep( 1000 * 60 * 60 * 2 }
          catch ( InterruptedException e )
             break;
And in the servlet class you normally had this, do this:
Thread t = new Thread( new MySleepingThread() );
// This starts the thread and eventually calls the run() method, starting your loop on a separate thread, so this one will continue.
t.start();.P.

Similar Messages

  • Servlet crashes TOMCAT

    I am experimenting with buffered images in a servlet. This "Hello World" servlet crashes TOMCAT.
    java version "1.4.1"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1)
    Java HotSpot(TM) Client VM (build 1.4.1, mixed mode)
    JAVA_OPTS '-Xmx512m -Djava.awt.headless=true'
    ----servlet begins----
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import Acme.JPM.Encoders.GifEncoder;
    public class MijnPollServlet extends HttpServlet
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    doPost(req,res);
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    BufferedImage image=
    new BufferedImage(100,100, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    g2.setColor(Color.blue);
    g2.fillRect(25,25,50,50);
    g2.drawString("Hello World!", 10, 10);
    ServletOutputStream out = res.getOutputStream(); // binary output!
    res.setContentType("image/gif");
    GifEncoder encoder = new GifEncoder(image, out);
    encoder.encode();
    ----servlet ends----
    If I run the servlet with the "g2.drawString("Hello World!", 10, 10);"
    commented out there is no problem.
    Is there something I am missing here?
    Thank you,
    -William

    The whole Tomcat crashes, and no exception
    displayed.
    Do I have to write the log file, or it's kept by
    Tomcat itself?yes, tomcat writes a log file, you find it in the tomcat dir. but it's just very highlevel. Having a look in it could help.
    Is there a way to write a log file by myself?sure. you could get the log file from tomcat by getting it from the ServletContext:
    ServletContext = getServletContext();
    ServletContext.log("text to log");
    When I view the output window in Forte, it doesn't
    even write that Tomcat crashed.
    I use Tomcat that is installed with the last version
    of Forte(Sun 1 Studio, update 1), I guess it's the
    last version of Tomcat also.No. The lastest is 4.1.12 and i guess it's 4.0.4 with forte.
    Get Tomcat standalone from jakarta.apache.org and try to run your servlet with the standalone tomcat. this could help since i also expirenced problems sometimes with the forte-integrated tomcat.

  • MBP not recovering from sleep / Strange 'freezing' crashing...

    I'm having a VERY strange issue here.
    Over the past week, my MBP (only 4 months old?) has become suddenly unable to recover from sleep. I'll be watching a movie in FrontRow, 'sleep' it from my Apple remote, and then when it re-awakens, the screen fires up but it's black (as in, the backlight is obviously on and drive/fan spins up, but no image on display).
    Then, just tonight, I've been working on some websites, nothing too intensive, maybe running iTunes and Safari in the background alongside 'DreamWeaver', and the whole system just FROZE. I can't type, I can't move the cursor, the screen is completely frozen. I kept waiting for the familiar 'kernel panic' screen to appear or something, but I've never seen any Apple machine do this before...
    It's kinda worrying as I'm not particularly stressing the machine or anything.... any ideas??

    Try setting your SMC controller - especially if its a wake and sleep related issue.
    http://support.apple.com/kb/HT3964
    Likewise in Utilities, open 'Console' to look at your logs. There will be diagnostic messages (I hope) about the crash.
    You could also run the activity monitor to make sure processes aren't topping out and hogging the CPU.

  • BLOB access in servlet crash.. HELP !!!

    Linux Mandrake 7.02 / Sun SDK 1.2.2 SE / Tomcat 3.1 / Oracle 8.0.5 / JDBC 1.2.X
    I've got a table which have a LOB column.
    I want to retrieve this LOB.
    When I do it in a java program, all is well, I get the image in the LOB.
    When I put the code in a servlet (ran in Tomcat), Oracle crash with error :
    ORA-03115: unsupported network datatype or representation
    I checked CLASSPATH for the two runs, all seems ok ...
    I don't understand the meaning of this error
    Please HELP !!!

    [http://forums.sun.com/thread.jspa?threadID=5350426]
    Crossposting without notification is very rude. Please stick to one topic.

  • Servlet Crashing in IE 6

    I have had a problem displaying servlet pages in IE 6. Most of the time the pages display fine but occasionaly long pages will crash and I will get a "Page Cananot Be Displayed" html error. If i keep trying to display the same page it will mostly continue to crash but ocasionaly it will display properly. I switched to a Netscape 4.7 browser and it worked perfectly each time. However, I was unable to print the displayed page because I do not cach the pages. I upgraded Netscape to 6.2 and it worked fine, displaying pages and allowed me to print. Obviously IE processes html pages diferntly than Netscape, does anyone understand these difernces. I have a controled enviorment here and can force users to use Netscape, but that will not work on interner applications. How can I get these page to display consistantly in IE.
    Thanks

    How long are the pages that crash? Are they very long?
    Couldn't you look at splitting up the pages with links between them, rather like these forums, or google search results?

  • "Sleeper Cell Episode" Crashes iTunes 6.0.2

    Purchased "Sleeper Cell" season 1 episodes on iTunes. All episodes can be viewed except the 5th episode "Soldier."
    Every time I try to view it crashes iTunes 6.0.2.
    I have trashed the iTunes Pref and restarted Mac. Still the same thing.
    Trashed episode and re-downloaded it, same deal!
    Anyone have ideas?? Or is that episode corrupt on the Apple side.
    Powerbook   Mac OS X (10.3.9)   iTunes 6.0.2

    That's BS!!! I expect more from Apple!
    I had the same problem after upgrading to 6.0.2. The solution was to uninstall 6.0.2 and reinstall 6.0.1.
    (I tried uninstall\reinstall of 6.0.2 and restore of iPod)
    I called Apple to obtain the prior version (which I deleted like a numb skull) and they refused to provide it. Fortunately, I was able to obtain from filehippo.com
      Windows XP  

  • Netflix watch instantly crashes all browsers

    About a month ago Netflix started giving me problems while watching instantly. Audio wasn't syncing with video and it would skip and freeze. I tried uninstalling and reinstalling Silverlight, but that didn't work. After corresponding via email with micrsoft silverlight support and a complete uninstall and reinstall of silverlight and testing it on other websites, we determined that silverlight is not the issue. I then tried Netflix support, which was terrible and of no help at all. Now Netflix crashes all browser (Safari, Firefox, & Chrome) upon loading. Netflix streaming works fine on all other computers in the house. I have all of the most recent updates of all browsers, I've tried repairing disk permissions and I'm running OS X 10.6.8 with all current software updates. I'm not sure what else to do. Please help.

    Sound like a corrupt cache issue, the #12 OnyX routine here should clear it.
    Step by Step to fix your Mac
    Do some of the other steps too just to check things out, even #16 or #18 if necessary to isolate the issue if the above steps don't resolve it.

  • Servlet crash

    I have a servlet (singlethreadmodel) running on a tomcat server.
    and there are some 20 clients (applets) connected to the servlet. it is netwrok game in which each player sends data to the servlet. after each of them finsihes giving the input some calculations are made on the server side.
    all these clients have a timer and keeps checking if everyone has finished. when everyone is done with the inputs, at the next timer the servlet responds with the data.
    this process is one round and there several rounds like this..
    the problem is the servlet some times hangs, stops responding to the clients and the client keeps waiting for the response and the whole game is hung.
    some times it crashes.
    can anyone help me here..what might be the problem.

    Hii .. this is the actual info abt -X options in JVM.
    Xmsn
    Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 2MB. Examples:
    -Xms6291456
    -Xms6144k
    -Xms6m
    -Xmxn
    Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. Examples:
    -Xmx83886080
    -Xmx81920k
    -Xmx80m

  • Servlet Crashing JVM!!

    We have been having a problem lately with Java crashing on our production machines. All of the java we use is wrapped around servlet applications, and I am getting the following error in the Tomcat log... any ideas on what can cause this?
    SIGSEGV 11 segmentation violation
    si_signo [11]: SEGV
    si_errno [0]:
    si_code [1]: SEGV_MAPERR [addr: 0xff00]
    stackpointer=D999FF18
    Inconsistent thread : best efforts attempt (may fail)
    "Thread-8 Labels" (TID:0x27858f8, sys_thread_t:0x2785830, state:CW, thread_t: t@2324, threadID:0xd90f1d70, stack_bottom:0xd90f1d70,
    stack_size:0x1fd70) prio=5
    [1] java.lang.Object.wait(Object.java:424)
    [2] com.mapinfo.graphics.text.ba.run(Unknown Source)
    [3] java.lang.Thread.run(Thread.java:478)
    -------------------

    Sounds like you've got a problem with your native thread libraries, or something native (and nasty) is happening in that 'com.mapinfo.graphics.text.ba.run' package.
    You didn't say which OS, etc... you are running, but make sure you have the latest stable kernels and thread libraries installed.
    What you are showing is most likely not a JVM issue.
    - K

  • MBP sleep wake up crash and restart

    For quite some time my MacBook Pro has been having a fairly serious waking up issue (my hard drive has now been corrupted and forced me to reinstall mavericks twice because of it), where it will crash and restart if the lid is opened and the computer wakes up after the computer has been to sleep for some time and the battery level is below 60-80% (usually). It rarely (if ever?) has happened if the computer is attached to the mains or if the lid has only been closed for a short while.
    Often it will get to the log in screen, freeze and then the computer will simply turn off and reboot, after that the computer will be completely fine until I close the lid and start over again. I'm not sure how much of a software fault it is since it has happened both times I've reinstalled the OS. At the same time I would rather it not end up being a hardware issue as I'm not insured and I've voided the warranty by changing the hard drive to an SSD myself.
    So far my guess is that something is wrong with the hard drive (because it was shortly after installing the SSD that this began happening) or there's something wrong with the battery that means it simply can't provide enough power to the system when waking (since this problem only really occurs when waking on battery power and when it's below a certain level), but really these are just ideas. I'm wondering if anyone knows of a software solution for this issue, or whether I should give up hope and just pull out my wallet to get it (hopefully) fixed by Apple? 

    Changing to the SSD wouldn't void the warranty. Here's something you might want to try. Put the SSD in an external enclosure and see if it runs fine from there. If it does, you probably have a bad SATA cable which is what connects the drive to the motherboard.
    http://www.amazon.com/Sabrent-2-5-Inch-Aluminum-Enclosure-EC-TB4P/dp/B005EIGUD4/ ref=sr_1_3?ie=UTF8&qid=1398261464&sr=8-3&keywords=2.5+enclosure

  • Servlet crashes on preparedStatement.close()

    Hello Everyone ,
    I have a servlet that gives out database information. Depending on the request parameters , some prepared statements that I declare before my try block may or may not be used. All statements and resultSets are initialized to null. If I determine the request is bad my servlet goes to an else block, then the finally block to close statements and stuff. Unfortunately, when it hits a preparedStatement that wasn't used, it outputs a HTTP Status 500 java.lang.NullPointer exception. I have never had this happen before ?
    P.S I output my xml before the try block, so how come I see the error and not my xml, or a combination of both ?

    As mentioned earlier by others, in your servlet code somewhere you are doing some operation on an object which is null. From server error log see the stack trace. Locate the exact place of NullPointerException and fix it.
    I hope you know where log files are generated in server. If you need help fixing the root cause of NullPointerException please post your code snippet here.
    Thanks,
    Mrityunjoy

  • Step Over not working with Remote Debugging of Servlets with JRUN

    Platform: JRun 4, JDK 1.4.1, JDev 9.0.3
    using JPDA and copied jpda.jar to JDEV_HOME/java1.2/jre/lib/ext and set path to jar in app server path.
    using debug args: java.args=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5000
    ok, I'm able to attach JDeveloper to JRun and remotely debug by jumping from breakpoint to breakpoint but stepover causes JDeveloper to continue execution to completion or to next breakpoint. Any idea why step over does not work? The only way to halt execution during remote debugging is by using breakpoints.
    Thanks in advance for any insight to this issue.

    Hi Bob,
    I think OTN ate the other thread. It says there are 4 replies, but it won't display them. Here's my latest reply.
    I just noticed something interesting from your original message. You say you are using JDK 1.4.1 for the app server (that's good) and you are using JDev 903. But you say you have copied jpda.jar to JDEV_HOME\java1.2. That doesn't make sense because JDev 903 didn't have a java1.2 directory; I think JDev 903 has a jdk directory which contains JDK 1.3 (actually 1.3.1_03 or something like that).
    Also, jpda.jar is really old and the directions for using jpda.jar and for putting jpda\bin on the app server path is really old. Those directions were needed for JDK 1.2 because JPDA was released AFTER the JDK 1.2 was released. Starting with JDK 1.3, jpda is built in and you don't need the jdpa.jar or the jpda\bin, etc.
    All this reminds me that in JDK 1.2, HotSpot had bugs where stepping didn't work!!! I'm almost positive that this is what you are experiencing. Here is my advice:
    1. Make absolutely sure that you are using JDK 1.4.1 (or at least JDK 1.3 or later) for running your app server. Make sure that you are not using JDK 1.2 - you may have modified your app server so that it uses JDEV_HOME\java1.2\bin\java.exe[i]Long postings are being truncated to ~1 kB at this time.

  • Native call in Servlet crashing tomcat

    I can execute the class from the unix prompt (invoking the main) and it works fine, however when I invoke it withing a servlet or jsp, i get a core dump.
    It seems to be a treading issue. I am including the tread dump of ONLY the thread that died.
    Any advice on getting this going would be appreciated.
    Derek
    SIGSEGV 11* segmentation violation
    si_signo [11]: SIGSEGV 11* segmentation violation
    si_errno [0]:
    si_code [2]: SEGV_ACCERR [addr: 0x0]
    stackpointer=ba12a2d4
    Full thread dump Classic VM (Caldera-UNIX-J2SE-1.3.0_02:*fixes-OU8*fixes-UW7*FCS-OSR5*:020322-03:47, native threads):
    "Thread-9" (TID:0xbca3aa50, sys_thread_t:0x83e7738, state:R, native ID:0xe) prio=5
    at JavaToCPageInterface.sendMessage(Native Method)
    at doit_3._jspService(doit_3.java, Compiled Code)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java, Compiled Code)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java, Compiled Code)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java, Compiled Code)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled Code)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java, Compiled Code)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java, Compiled Code)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
    at java.lang.Thread.run(Thread.java:484)

    More Info:
    j2sdk 1.3.1
    Tomcat 3
    The program executes fine as a stand-along app, however if it is called from withing a servlet or JSP, Tomcat core dumps.
    Have tried -Xss10m as a parameter, however it does not work. I have also tried both green and native threads.
    Thanks,
    Derek

  • IOS 5 rapid battery drain (including in sleep mode), springboard crashes: FIX!

    OK folks, I resolved all issues in their entirety with the help of a genius bar tech who recognized that I was very technical.  WARNING!  Sync or backup your phone prior to performing these steps!
    First, do a MANUAL download here of the IOS 5 that matches the model of phone you have and save that image to your desktop or some other place on your computer.  PUT THE PHONE IN DFU MODE, not recovery mode (google on how to accomplish if you are not familiar).  The raeson why you are going to put in DFU mode is so that you will be able to not only get a good copy of IOS 5 installed but to ensure that your firmware is not corrupt, which appeared to be the case with my battery drains and springboard crash issues.
    One you are in DFU mode (your screen should be black the whole time, again google), open itunes and it will give you a warning that says that your phone needs to be restored.  If you are on a mac, hold down the option key and press RESTORE in iTunes.  This will open up a box that will allow you to "locate and select" a file, which will be the IOS 5 image that you manually downloaded before.
    Once you do, the iphone will start to restore.  After all of the restore cycles have been completed, you will be prompted in iTunes to either setup as a new phone or restore from backup.  I USED RESTORE FROM BACKUP so that I could preserve all of my settings.  Everything has been working PERFECTLY ever since completing these steps!  I will probably go ahead and make a separate thread related to this fix.
    I hope this helps!  Scott

    Their is another thread in here that mentions turning off reporting of Diagnostics data (Settings --> General --> About --> Scroll to the bottom/Diafnostics --> Select Don't send.
    Another item to check are you E-mail accounts. If you only have one account in this section then you should be good. If you have multiple and have every feature turned on (Contacts, Calendars, Reminders, etc) then your device could be trying to update to all and timing out which would get it to retry over and over again. I have turned off all the other features for my email accounts with the exception of iCloud and my battery life is looking good.

  • Mapviewer servlet crash on OC4J 11g TP4

    Hi!
    Is it normal or not? If I try to deploy mapviewer.ear (10 or 11 pre) on OC4J 11G TP4 it make exception on
    http://.../mapviewer/faces/home.jspx
    Is it planing compatibility for these Oracle products? And on which release?

    Mapviewer is not supported on OC4J 11g TP4.
    Please note that the going forward position for Oracle Fusion Middleware R11 is that OC4J is being replaced with WebLogic Server.
    -steve-

Maybe you are looking for