Search This Blog

Thursday, October 30, 2008

Lamda Probe for Tomcat

Recently was involved in a Garbage collection/memory management issue at work. After the problem abated, I was on the search to see if there are any open source memory profiling and monitoring tools for tomcat. For example, a simple way to introspect the various sessions in the container and the objects therein. Investigate the size of the session and more.

During this search, I stumbled upon this article by my Edmon Begoli regarding an open source tool for Tomcat called Lambda Probe. The article is very well written with nice examples etc.

Following the article, I installed the Lamba probe's WAR file in my development tomcat container and accessed the web app in a jiffy and was therein pleasantly surprised at the features the tool delivered.

I was able view the number of sessions in an application, the attributes held there in, the size of the attributes, whether the session and/or attributes there in are serializable or not, Servlet Context attributes.

It was also nice to view the memory consumption of the system and the various memory spaces, all after adding a single line, -Dcom.sun.management.jmxremote, to the JAVA_OPTS. I could view the memory consumption of the system with graphs of all the memory spaces, eden, survivor, perm gen etc.

An additional feature that I liked was one could view JSP's from the console itself, compile a jsp and view the generated Servlet code as well.

One can also view statistics regarding the requests performed etc. Statistics regarding requests and so much more.

In addition, the UI is rather well designed. Simple and intuitive with good Web 2.0 LNF. It makes use of prototype.js and scriptaculous.js from what I could gather.

Quite nice I must say for an open source tool. I will be using Lamda Probe definitely in my development environment to continue evaluation and assist me with debugging without having to write custom code to capture and display all this information.

The only joke in all this is that I was unable to access their site after my initial download, lol! After some googling, the tool can be obtained from HERE.

Monday, October 20, 2008

SOAPUI REST Support

Some time ago, I had blogged lamenting the absence of a nice testing tool for REST. At that time, a gentleman from the SOAP UI team mentioned the upcoming support for REST from Soap UI.

I could not help but try out the Beta release of the same. SOAP UI should probabaly change their name to WsUI (Web Service UI). These guys seem to be doing a pretty neat job. If their SOAP UI was any thing to go by, their REST support should turn out to be quite solid.

So I went to the SOAP UI site, downloaded the free version (SOAP UI 2.5 beta1) and installed the same. SOAP UI supports reverse engineering from WADLS quite like they do with WSDLs. An example of using WADL with SOAP UI is documented on their site.

In my current organization we do not as 'yet' use WADL, I wanted to test out the ease in which one could test REST calls using SOAP UI. Operations such as GET/POST etc.

A simple web service that services two resources, "/products" returning a list of JSON products and "/order", a resource that allows for POST/GET/PUT and DELETE of Orders.

When the SOAP UI application opens, clicking on "New SOAPUI project" brings forth a dialog where in one can either choose use specify a WADL or provides the Option for a REST Service as shown below:







Clicking OK on the above, brings forth a dialog that allows one to create a Service as shown below:





Note the end point supplied points to the Web app. In addition, select the check box to create a Rest Resource before clicking OK to bring forth the Rest Resource Dialog:



After accepting the above dialog, proceed to the Dialog shown below to be able to execute a call to the web service to obtain products.



In the above dialog although I specified application/json as the media type, the JSON tab on return of JSON content does not display the same. However, in the RAW tab, one can view the JSON content.




The same process above can be followed in order to create an order resource with different types of HTTP operations supported by the resource.

Pretty neat..makes testing REST Web Services rather easy. In particular this looks like a boon to the Tester as well as they now have an easy way to test out Rest services. One can also set up load tests, intercept request/response using tcp mon and or pull SOAP UI into eclipse as a plugin.

I have attached herewith a Maven project that represents a simple web service. There are two resources provided, "/products" and "/order". The former returns a JSON representation of products. On the latter resource, issuing a GET via "/order/1" will return back an Order. You can create an order easily by using POST. The xml for the same is:

<?xml version="1.0" encoding="UTF-8" standalone="yes">
<order>
<lineItem>
<itemId>12123</itemId>
<itemName>XBOX 360</itemName>
<quantity>2</quantity>
</lineItem>
</order>


A sample SOAPUI project for the same can be obtained from HERE. Import the same into SOAP UI. Execute "mvn jetty:run" on the Maven project to start the webapp. Subsequently execute each resource call using SOAP UI, Create Load Tests, Create a WADL, Enable TCP monitoring, Enable JAXB support, WADL.....Rock on! :-)))