This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, I want to use the assert statement from JDK 1.4 in my servlets in Tomcat 4.1.24 (Win). I know I have to enable it by a command line parameter -ea. But how do I tell this my Tomcat server? I tried to set the CATALINA_OPTS shell variable (CATALINA_OPTS="-ea") but it didn't work. Any ideas? Thanks, Tom
The potential problem with this: If your servlet throws an assertion error, is the container designed to handle it? I think not, because assertions aren't meant to be handled by code (even though they can be).
So... umm.... won't that cause the current thread to die with an assertion error? How would the container notify the browser that something had gone wrong? Would it perhaps kill the container?
I'd be interested to hear your results...
Also... moving this from Servlets -> Apache/Tomcat
Joined: May 08, 2003
First of all, sorry for posting to the wrong forum. @Rene: Unfortunately, it didn't work. Is this all you did to get it working? BTW: Is there a difference between CATALINA_OPTS and JAVA_OPTS? Both are used as Java runtime options. @Mike: The webapp should stop with an assertion error, because then there went something completely wrong! What I want to do is the following: Replace:
I'd prefer that my container isn't dying in this case. Tom
Originally posted by William Brogden: The servlet container catches every Throwable that a request Thread can throw so don't worry about an AssertionError stopping the whole servlet engine. Bill
In other words, you can expect to see the stack trace come back in the browser window. The response code is probably going to be "500". Just as a matter of good practice, for production I'd put an intercept that logs the stack trace (actually I believe it should be already) and display a "System error, webmaster notified" page. Having a stack dump come back to a user make your app look less reliable (admittedly, if it died, it is less reliable, sut still...). Also, that's information that you probably don't want unfriendly eyes to see.
Customer surveys are for companies who didn't pay proper attention to begin with.
Did you remember to compile your servlet with the option '-source 1.4'?
Joined: May 08, 2003
Ok. Solved it - at least partly: In windows you are able to start Tomcat in 2 ways: 1. Start->Programs->Tomcat-> Start Tomcat which does the following: C:java.exe -jar -Duser.dir="F:\Tomcat 4.1" "F:\Tomcat 4.1\bin\bootstrap.jar" start 2. Over the command line like this: F:\Tomcat 4.1\bin\startup.bat I used version 1. Obviously, I have to enter the "-ea" option there. And yes, it worked. Then I was curious if it'll work if I use version 2. Surprisingly, no web application was available (even the examples weren't) and I was not able to login to the manager console... How do you start your Tomcats under Windows? Do know this problem? BTW, thank you for your hints so far. Tom