Prev: encrypted javamail MimeMultipart
Next: Urgent DIRECT CLIENT Openings: 1.Websphere Portal - Developer, 2.ITIM-TAM Analyst, 3. IT Project Coordinator / Project Analyst
From: Mike Schilling on 13 Jun 2010 00:27 "ClassCastException" <zjkg3d9gj56(a)gmail.invalid> wrote in message news:hv1kf6$rdk$1(a)news.eternal-september.org... > On Sat, 12 Jun 2010 01:07:42 -0700, Mike Schilling wrote: > >> "ClassCastException" <zjkg3d9gj56(a)gmail.invalid> wrote in message >> news:huuvm3$c4e$1(a)news.eternal-september.org... >>> On Thu, 10 Jun 2010 22:55:59 -0700, Mike Schilling wrote: >>> >>>> "ClassCastException" <zjkg3d9gj56(a)gmail.invalid> wrote in message >>>> news:husivb$hsb$3(a)news.eternal-september.org... >>>>> On Thu, 10 Jun 2010 20:38:23 -0700, Mike Schilling wrote: >>>>> >>>>>> "ClassCastException" <zjkg3d9gj56(a)gmail.invalid> wrote in message >>>>>> news:hus9o8$g1n$6(a)news.eternal-september.org... >>>>>>> On Thu, 10 Jun 2010 19:54:51 -0700, Mike Schilling wrote: >>>>>>> >>>>>>>> "ClassCastException" <zjkg3d9gj56(a)gmail.invalid> wrote in message >>>>>>>> news:hus76c$g1n$2(a)news.eternal-september.org... >>>>>>>>> I think the usual situation will be that a) you don't catch Error >>>>>>>>> and b) servlet containers etc. run servlets etc. in separate >>>>>>>>> threads and deal with it gracefully if any of these threads >>>>>>>>> abends. If you have multiple threads, provide some interrupt >>>>>>>>> mechanism that can be triggered. >>>>>>>> >>>>>>>> A servlet container will handle each request in a separate thread, >>>>>>>> and direct that thread to the servlet that should handle it. One >>>>>>>> request's thread erroring horribly doesn't prevent further >>>>>>>> requests from being processed by that same servlet. Preventing >>>>>>>> any further processing would require some management operation >>>>>>>> that disables the servlet, or more likely its containing web >>>>>>>> application. >>>>>>> >>>>>>> Euuww. That means you need to tell the servlet container to >>>>>>> unregister you, or else set a public static mutable error flag that >>>>>>> makes all subsequent instances prompt-fail, or something. Global >>>>>>> variables. Ick! >>>>>>> >>>>>>> Does the servlet<->container API/protocol/whatever not include an >>>>>>> explicit way for a servlet to signal a fatal error to the >>>>>>> container? Let alone to perform just-once initialization, prior to >>>>>>> handling requests, which can fail? >>>>>> >>>>>> Yeah, that you can do. There's an init() method, and if it throws >>>>>> an exception the servlet is never enabled (at least, in containers I >>>>>> know of. Not sure if that's part of the spec.) >>>>> >>>>> Ah, then Todd should probably be doing these checks in the init() >>>>> method and throwing an exception if they fail. >>>>> >>>>>> But even without that, there's no need for anything but a private >>>>>> field used by the (single) instance of the servlet class. Multiple >>>>>> threads -- single instance. >>>>> >>>>> Global variables by any other name ... *sigh* >>>> >>>> A private instance field is a global variable? >>> >>> Not normally, but in this case it's sort-of one in disguise. >> >> It represents the state of the object (the servlet), which is what >> instance fields are supposed to do. This works quite well for >> intermittent problems, say losing the connection to an underlying DBMS. >> The servlet can retry the connection every N seconds, while rejecting >> all requests that come while it's down. > > Okay, this looks like a reasonable use. > >> For unrecoverable initialization failures, throwing an exception from >> init() makes more sense. > > Yes, this arose elsewhere in the thread and seems like the best solution > to Todd's problem. > > Let me clarify: a global mutable error flag that isn't actually supposed > to change more than once is an ugly hack to work around the lack of > something like init(), had it proved to be lacking. You insist on calling a private instance field "global". > > A shared mutable used to indicate a temporary error condition that will > be toggled when the condition arises and when it dissipates, repeatedly, > is a non-hacky use of a widely-visible mutable. > > The former leaves the bad taste; the latter does not. >
From: Lew on 13 Jun 2010 00:49 ClassCastException wrote: >> Let me clarify: a global mutable error flag that isn't actually supposed >> to change more than once is an ugly hack to work around the lack of >> something like init(), had it proved to be lacking. Mike Schilling wrote: > You insist on calling a private instance field "global". Inigo Montoya: "You keep using that word. I do not think it means what you think it means." - The Princess Bride, 1987 -- Lew
From: MarlonBrando on 13 Jun 2010 11:40 On Jun 10, 10:52 pm, Todd <todd.heident...(a)gmail.com> wrote: > Hello, > > I have a Java process that when it is improperly configured, it needs > to halt (programmatically). My understanding was that > System.exit(status) was the way to do this. There has been some > grumbling that there may be another, better way to do this, but nobody > has an specifics. References have been made to Eclipse and JBoss, but > Google hasn't turned up any useful results. > > Anybody here know anything about this? I know it is a bit ambiguous, > but I am searching the darkness with a penlight for answers to this. > > Thanks, > Todd in our program, we use linux crontab to start the java script and use the exit() to halt the jvm.
From: ilan on 13 Jun 2010 15:14 Lew <noone(a)lewscanon.com> writes: > ClassCastException wrote: >>> Let me clarify: a global mutable error flag that isn't actually supposed >>> to change more than once is an ugly hack to work around the lack of >>> something like init(), had it proved to be lacking. > > Mike Schilling wrote: >> You insist on calling a private instance field "global". > > Inigo Montoya: "You keep using that word. I do not think it means what > you think it means." > - The Princess Bride, 1987 `I don't know what you mean by "glory",' Alice said. Humpty Dumpty smiled contemptuously. `Of course you don't -- till I tell you. I meant "there's a nice knock-down argument for you!"' `But "glory" doesn't mean "a nice knock-down argument",' Alice objected. `When I use a word,' Humpty Dumpty said, in rather a scornful tone, `it means just what I choose it to mean -- neither more nor less.' `The question is,' said Alice, `whether you can make words mean so many different things.' `The question is,' said Humpty Dumpty, `which is to be master -- that's all.' Alice was too much puzzled to say anything; so after a minute Humpty Dumpty began again. `They've a temper, some of them -- particularly verbs: they're the proudest -- adjectives you can do anything with, but not verbs -- however, I can manage the whole lot of them! Impenetrability! That's what I say!' `Would you tell me please,' said Alice, `what that means?' `Now you talk like a reasonable child,' said Humpty Dumpty, looking very much pleased. `I meant by "impenetrability" that we've had enough of that subject, and it would be just as well if you'd mention what you mean to do next, as I suppose you don't mean to stop here all the rest of your life.' `That's a great deal to make one word mean,' Alice said in a thoughtful tone. `When I make a word do a lot of work like that,' said Humpty Dumpty, `I always pay it extra.' `Oh!' said Alice. She was too much puzzled to make any other remark. `Ah, you should see 'em come round me of a Saturday night,' Humpty Dumpty went on, wagging his head gravely from side to side, `for to get their wages, you know.' (Alice didn't venture to ask what he paid them with; and so you see I can't tell you.) `You seem very clever at explaining words, Sir,' said Alice. `Would you kindly tell me the meaning of the poem called "Jabberwocky"?' From Chapter 6 of _Alice in Wonderland_ by Lewis Carroll.
From: Lew on 13 Jun 2010 17:48
ilan wrote: > `You seem very clever at explaining words, Sir,' said Alice. `Would you > kindly tell me the meaning of the poem called "Jabberwocky"?' > > From Chapter 6 of _Alice in Wonderland_ by Lewis Carroll. That is NOT from /Alice in Wonderland/, the correct title of which, btw, is /Alice's Adventures in Wonderland/. That is a quote from /Through the Looking-Glass/, Chapter VI, a different book by the same author. -- Lew |