Prudence
The Scalable REST/JVM
Web Development Platform

Creative Commons License

Debugging

Logging

Logging is the developer's best friend. Use it wisely, and you'll be able to clearly analyze the flows of control, code and data.

Management and Monitoring

Another useful debugging feature is the JVM's built-in support for management and monitoring, which lets you use tools such as VisualVM and JConsole to probe into threads and memory use.

The Debug Page

The debug page is returned as a response whenever an exception is thrown in your code, which is not handled (or, if there is a bug in Prudence!).
Though very useful during development, you'd probably want to turn it off for production systems. Simply set the showDebugOnError setting to false. Note that in that case, you might want to capture errors, sending them to a friendly, apologetic page for the users. See error capturing.
The debug page shows you the following information about the conversation:
  • A stack trace of the exception, with a link to a view of the source code.
  • The reference (URI) used by the client, including the application's root reference, the virtual host reference, the original version of the reference (it might have been altered by filters along the route), and whether it was captured.
  • The query of the URI.
  • Cookies included in the request.
  • Breakdown of the request metadata: media types, character sets, encodings, languages, etc.
  • Request conditions, if included.
  • Entity data, if available and not yet consumed by your code.
  • Caching directives, if included.
  • Information about the client: IP address, browser, operating system, user-agent, etc.
  • Request attributes, including captured attributes.
  • Warnings, if included.
  • Underlying JVM stack trace.

Live Viewing of Source Code

With debug mode enabled, Prudence supports live viewing of source code in /web/dynamic/ and /resources/, with syntax coloring provided by Jygments. Links to source code are provided by the debug page, but you can also GET source code directly via:
  • Prefixing URIs with "/sourcecode/"; see the showSourceCodeURL setting. For example, use GET on "/sourcecode/support/forum/" to see the source code for the resource or dynamic page at "/support/forum/".
  • Adding a "?source=true" to the query for URIs of /web/dynamic/ pages.
In both cases, you can add "?highlight=n" to the query, when "n" is the line number to highlight.

Breakpoints?

As of Prudence version 1.1, you cannot set breakpoints in your code, unless it's in Java. Future versions of Prudence may allow breakpoints for some flavors, as supported languages add more debugging features. However, we do not feel that this is such a great loss, or that it would adversely affect your ability to develop for Prudence. The combination of robust logging and the debug page can go a long way towards helping you diagnose your problems. Debugging highly concurrent applications, such as network servers, does not work very well with breakpoints, anyway.