Way Down the Line
Adding arbitrary web app debug code at runtime
"Debugging" can mean a lot of different things. The classic use case has a developer sitting at his or her machine, using a low-level debugger like
jdb or IDE-based equivalents to inspect the state of variables, threads, objects, etc. And that's great. But there's also a sense of debugging involved in seeing a production system misbehaving and trying to find some way of determining what it's doing and why. Particularly with web apps, these situations aren't amenable to hooking up a debugger, because of the remote deployment, the fact that debugging may not be enabled, etc. And that's assuming the problem is amenable to that style of debugging.
Admit it: at least once, you've probably wanted to throw an arbitrary
System.out.println() into a remote, running application, if only to start to figure out what the heck's going on. But of course, that means recompiling, restarting, and lots of other impracticalities. What you could really use is a maintenance servlet that would let you get in and do stuff at runtime.
The servlet we want to write needs to be able to hook into any resource provided by the web server and allow the user to inspect any part of it. To be able to gather the required information, it might require flow-control constructs and loops. This leads to one solution: to make the servlet able to execute a script sent by the client (i.e., the browser). The script will have not only the ability to access any server resource, but by manipulating host objects representing a HTTP request and response, it will be capable of communicating back to the client.
This is a wide-open technique, which has some obvious benefits and hazards -- check it out, think it over, then let us know what you think in the article comments.
Vikram Goyal continues the cross-blog discussion of employment in Live and let code, featured in today's Weblogs:
"Programmers and Managers have a symbiotic relationship... I don't fully pretend to understand what they do, while they don't pretend to tell me how to code."
Rich Unger shows off A simple NetBeans module, written in NB 5.0:
"As promised, here's a recap of a simple module I built to help me test a bugfix."
Debugging on J2ME/CLDC devices, Oyvind Bakksjo writes:
"Debugging programs running on real J2ME/CLDC devices is hard and frustrating. Some things can be done, though."
In Projects and
the Ninth Jini Community Meeting takes place October 19-20 in Chicago. "The meeting will run for two full days (Wednesday and Thursday) and be filled with a variety of technical, business/marketing, and general sessions." You can also get more info on previous Jini Community Meetings.
The Mac Java Community points out the availability of Apple's Xgrid agent for Java. "The goal of the project is that by using Java a completely cross-platform Xgrid agent can be produced. Using this agent it would be possible to build multiple platform Xgrid clusters that could be used to run any embarrassingly parallel tasks."
In today's Forums,
jeffmutonho worries about
How do you keep up with all the new java technologies that are out so fast?I tried buying books , but end up not even reading half the material because there's too much to learn and so little time...
sbohmannconsiders the unintended consequences of a proposed feature in
Re: "string" primitive:
"I've always found it the worst of features of C# that I can never be certain whether operator == will compare by reference or value. This forces me to use if ((Object)a == (Object)b) ... on instances of a class I haven't used before or whenever I simply don't remember whether the class had implemented operator ==, or not. It is NEVER about brevity. It is NEVER about beauty. It is always only about clarity. Hitting some more keys on the keyboard doesn't hurt nearly as much as ALWAYS having to think about every single tiny detail, just because there are no consistent mechanics to understand, but merely a lot of possible different ways a type might have been implemented in order to manipulate the language's basic syntax."
In Also in
the article Struts-Velocity integration , features Struts Recipes co-author George Franciscus walking you step-by-step through integrating the Velocity Template Engine into your Struts applications. The result is a fast, flexible alternative to JSP, but with all the creature comforts you expect from Struts.
So, you're fixing bugs as fast as you can. Maybe you even have a rational process to prioritize the process. Great. Now when do you stop? In the ONLamp feature, How to Decide What Bugs to Fix When, Part 2, Scott Berkun (author of The Art of Project Management) says "you need to plan out, in advance, how you'll know when you're done. If you don't do this you'll spend hours arguing over whether code is done enough or not. If you're smart, and take the time earlier to define exit criteria, you'll set up your team to spend those hours coding instead of arguing."
In today's java.net
News Headlines :
Creates Continuations Sub-Project
- Castor 0.9.9
- KickJava.com - New
Registered users can submit news items for the
href="http://today.java.net/today/news/">java.net News Page using our
form. All submissions go through an editorial review before being
posted to the site. You can also subscribe to the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net News RSS
Current and upcoming Java
- September 20-21, 2005 - JCP Program Training and Communication sessions
- September 20, 21, 22, 28, and 29, 2005 - DataDirect Design Previews (five events: Washington DC, New York, Boston MA, Santa Clara CA, and Irvine CA)
- September 21-23, 2005 - BelJungle 2005
- September 22, 2005 - Hong Kong JUG - Monitoring and Managing in Java SE 5
- September 23-25, 2005 - New England Software Symposium 2005: Fall Edition
- September 26-27, 2005 - JXTA Kitchen
- September 28, 2005 - Lucent Developer Focus Event at CTIA Wireless Conference
- September 30-October 2, 2005 - Western Canada Java Software Symposium 2005
- October 5-7, 2005 - Java in Action
- October 7-9, 2005 - Greater Nebraska Software Symposium
- October 14-16, 2005 - Pacific Northwest Software Symposium
- October 16-20, 2005 - OOPSLA 2005
- October 17, 2005 - Workshop Eclipse RCP
- October 19-20, 2005 - 9th Jini Community Meeting
- October 21-23, 2005 - Greater Atlanta Software Symposium
- October 28-30, 2005 - Northern Virginia Software Symposium
- November 1-4, 2005 - Enterprise Java Architecture Workshop: San Francisco
- November 4-6, 2005 - Lone Star Software Symposium 2005: Dallas Edition
- December 7-10, 2005 - The Spring Experience 2005
- December 10-14, 2005 - ApacheCon 2005
- December 12-16, 2005 - JavaPolis 2005
Registered users can submit event listings for the
href="http://www.java.net/events">java.net Events Page using our
href="http://today.java.net/cs/user/create/e"> events submission form.
All submissions go through an editorial review before being posted to the
Archives and Subscriptions: This blog is delivered weekdays as
Today RSS feed. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.
Adding arbitrary web app debug code at runtime