Just another weblog

Multithreading Spring-Batch using Concurrent API

Posted by damuchinni on March 12, 2009

One of the recurrent task in my job is to create batch programs in Java.

Some are extraction batches (we get data from a DB and write it to an XML file), some are import (from XML to DB), and some are DB treatments only. All these batches are using Spring-Batch Library to do their tasks.

Spring Batch is a well thought-out library, that, among other things, allows you to:

Handle large data by splitting it in small chunks
Restart a batch exactly where it has stopped
Define how many handled chunks per commit steps
Automatic Rollback / Retry in case of error

The diagram below shows a typical execution of a batch:

To simplify things, let’s say a batch is composed of steps, and a Step is a Reader and a Writer communicating together.

At the beginning of the step, the Reader and Writer are opened
The Reader opens a cursor on the DB, using a query.
The Writer creates the XML file to write
Then for each element read by the reader (For each row of the result set, we convert it into a Java Object)
The element read is sent to the Writer
The Writer convert it to XML then write it to the file.
When the Reader returns null, that means no more data to process
The Step tells the Writer to flush all it’s data
The Step closes the Writer and Reader.

Recently, I was asked to optimize a slow extraction batch.

Profiling the code, I see that the Reader must execute 15 SQL requests to get all the data to send to the Writer. As all elements are handled sequentially, that meant 150 000 requests for 10 000 elements ! A quick look at the database status with a batch running showed me that the database was not fully utilized.

I decided to Multi-thread the queries done in the Reader. By default, Spring-Batch does not easily support Multi-threading, and I didn’t want to do much change in the existing code, so I used the famous Java Concurrent API features of Java.

In my multithreaded batch, the Reader don’t execute the queries to get data for the Writer, but instead creates a FutureTask, and adds it to a Multithreaded ExecutorService. This FutureTask is then send to the Writer which ony stores it.

When writer.flush is called, we get the data one by one from each of the FutureTasks. All the threads of the ExecutorService are busy querying the DB to fill the data for the FutureTask. Thus all the reading will be multi-threaded.

Next, let’s deep a little bit into the code:

We create a Callable class that will execute the queries, we suppose we want to read contracts from the DB:
protected class ContractCreator implements Callable
protected long elementId;

public ContractCreator (long elementId)
public Contract call() throws Exception {
// Called by the threads
// Execute all the queries here
// And return the real data object

The reader creates the ExecutorService with a pool of 10 threads:

protected ExecutorService executor=Executors.newFixedThreadPool(10);

Then the reader creates the Callable class for each element to read and submits it to the threads of the ExecutorService.

public Object read (ResultSet rs, int rowNum) throws SQLException {
long elementId=rs.getLong(“ELEMENT_ID”);
// Multithreaded execution
Future result=executor.submit(new ContractCreator (elementId));
return result;

The Future created is sent to the Writer which only stores it.

* We store all the contracts running in parallel here
protected List<Future> contracts=new ArrayList<Future> (10);

public void write(Object output) {
contracts.add((Future) output);

It’s only when flush is called that the Writer tries to get each contract and write them to the XML file:

public void flush() throws FlushFailedException {
for (FuturecontractCreator:contracts)
// Get the data read by the threads
// Will block until the data is avaiable
Contract contract = (Contract) contractCreator.get();
writeContractToFile (contract):

We then have now 10 threads querying the DB in parallel with little efforts ! All the basic thread / synchronization handling stuff is done by the Concurrent API, and the resulting file is exactly the same as with the single threaded example.

I hope this Spring-Batch example allows you to understand better the power of the Concurrent API of Java !


Posted in Springs | Tagged: | Leave a Comment »

Struggling with the tag

Posted by damuchinni on March 12, 2009

I found this to be another doozey, certainly it was partly my fault as I didn’t read the Struts2 documentation on this tag very well. The problem was there was only a very short description so I skipped to the examples as I thought they would be more informative.

Anyway, this tag acts as a way to include the result of an action in your JSP. Think of it like this:

Ok, so how do you use this tag, firstly here are the caveats about its use. Once you have these in your head your life will become magically easier:

This tag NEVER goes onto the value stack! This may not be strictly accurate but thinking of it this way is certainly useful. When you are within the body of the tag it is NOT possible to reference it in the normal way. You can apparently use the value=”top.myProperty” method (the keyword here is top which references the item on the top of the stack. If top doesn’t work try #top) but I didn’t try this. The reason for this is that the tag does not get an id or var value until AFTER the tag is closed;
Once the tag is closed it is NOT on the value stack at all! The item on the top of the value stack is the original action which called the JSP page which has the on it. Therefore, even though it now has a id or var attribute you cannot reference it. My guess is that this is because this is the second action that is executed in a single result. If the first action has a parameter called name and then the second action had a parameter called name as well, which value would go onto the value stack? As I say that reason is a guess but it would make sense to me. None of the discussions I read explained the reason why so I guess it is buried deep in frameworks architecture.
Here is some example code for you, this is in your JSP:

Notice that the tag is closed and does not have any value for the body in this case. This just suited my need but it can have a body. Just make sure you understand the above two bullet points to know which way you want it to work. This is the code for the execute method of my action:

String myPropertyToPutInTheRequestObject = “Hello World!”;
getServletRequest().setAttribute(“myPropertyKeyInTheRequestObject”, myPropertyToPutInTheRequestObject);
return SUCCESS;

What is going on in there? Well, remember that the action cannot be referenced because either it is not on the stack or it does not have a id or var? That means you cannot access it’s value as normal. To work around this we MUST put the property we want to access into the request object (or another place the JSP can access it such as PageContext, ServletContext etc.). Remember that this tag will not return the result if the parameter executeResult is not set to true. This means that we can return whatever we want as the result type and it will not make any difference. I return SUCCESS but you could return cabbage or footballs, the result will not be executed. If you need to change this behaviour then set executeResult to true. Next is the rest of the code for the JSP page, this goes after your tag has closed (in my case):

This spits out the value of the item we put in the request object during out action execution. We access the property in the request object using the #attr key which is a special key for looking in the available scopes. Notice that we do NOT access this in the standard way. We can’t access it in the standard way as there is no way to reference the action, remember it is never on the value stack after the has closed and we need to use the top keyword if we are within the body of the tag.

Posted in struts | Tagged: | Leave a Comment »

Google Voice: Internet Telephony on a New Height

Posted by damuchinni on March 12, 2009

Google was in text, it has started to intrude into our electricity and now It is in our telephones. Google Inc. introduced Google Voice the other day. The new service weaves traditional phone features with Google’s Gmail email product, allowing a person to store transcripts of voicemail phone messages in their email inbox and to find a specific nugget of information within a phone message as if trawling through a sea of emails – as Reuters reports. If you do not remember, Google Voice is based on the technology of Grand Central Communications, a company that Google acquired in July 2007.

Be it anything but one can not just deny the diversification Google makes week after week. Its almost amazing how wonderfully they are enhancing their brands by tagging one into another and thereby forming a complete google-o-sphere which is very hard to ignore unless you want to compromise on quality.

How Does it Work

The main benefit is Google Voice allows users to route all their calls through a single number that can ring their home, work and mobile phones simultaneously. It also gives users a single and easy-to-manage voice mail system for multiple phone lines.

Calls can be made two ways. One is for users to dial their Google Voice number and press 2 at the prompt. Or they can click a number in their online dashboard to have the service ring their phone, and then connect with the other party.

Unlike domestic calls, international calls are charged per minute and require users to open a Google Checkout account(here is how they push one of their less appealing products), which stores credit card numbers. Calls to landlines in the United Kingdom and France cost 2 cents per minute, while a call to a mobile line in France costs 15 cents per minute.

What is the Motif
The next question is, why would Google launch something like this for now. How do they benefit? Because as of now, there are no plans to bring out corporate facilities too. So a free consumer grade product at this time will not make that much sense. But Craig Walker, the group product manager assures us of the intention – Google Voice, which will be available to existing Grand Central users on Thursday and to the general public in the following weeks, provides another reason for people to spend more time on Google’s various online properties, which benefits the company.

He ends in an optimistic note..

There’s all sorts of things we can do down the road. But right now we’re just totally focused on getting the consumer product out.

Do You think its gonna hurt Skype if at all? Whats your take on this.

[Picture courtesy:]


Filed under Company, Google, News | | RSS 2.0 | Trackback this Article | Email this Article

You may also like to read
Net telephony issue referred back to regulator
Google Launches Voice Search in iPhone – ‘Sound’s Pretty Impressive
Why does my Google Desktop search contact internet?
Google Introduces Video and Voice Chat to Gmail, Interested?
Google Warns Australia of Going Back To Pre-Internet Era
Google launches a mobile internet bus in Tamil Nadu
BSNL Launches 3G Services in 12 Cities
Next Step in Google’s World Domination
Best and Worst Browsers – Choice of the Internet
Adobe Bundles Google Toolbar with Shockwave for Internet Explorer on Windows
Google.Com Banned in China?
Google Down!
Google to shutter radio ad business
Google Earth Rival for France
Google Internet Bus in India is Spreading the Value of Internet Across the Border

Looking forward to hear your thoughts.

Posted in Google | Tagged: | 2 Comments »

A Study: Ways To Make Web 2.0 Work In The Enterprise

Posted by damuchinni on March 12, 2009

The McKinsey Quarterly Report published a recent study by Michael Chui, Andy Miller, and Roger P. Roberts. The study spanned the last couple years and more than 50 early adopter enterprises. The purpose of the study was to gain insight into successful adoption of Web 2.0 technologies in the enterprise to improve participation and suggests vast amount of opportunities for Web 2.0 tools in the enterprise.

Web 2.0 covers a range of technologies. The most widely used are blogs, wikis, podcasts, information tagging, prediction markets, and social networks. […] What distinguishes them from previous technologies is the high degree of participation they require to be effective.

Paraphrasing the classification of the Web 2.0 technologies, the authors classify them into the following categories,

Collaboration – wiki’s, shared workspaces etc.
Communication – Offers broad communication capabilities via blogs, podcasts etc.
Collective Estimation – Harnessing the power of the collective, “crowd-sourcing” using information markets
Metadata Creation – tagging, curation and collaborative filtering
Social graphing – Social networking leverages connections between people to offer new ideas, solutions, applications
The capabilities that are unlocked by these tools are illustrated by the following graphic

The authors offer guidance, citing examples, on management imperatives required to help companies navigate the Web 2.0 landscape and succeed implementing these technologies.

1. The transformation to a bottom-up culture needs help from the top.

Web 2.0 projects often are seen as grassroots experiments, and […] successful participation, […] requires not only grassroots activity but also a different leadership approach: senior executives often become role models and lead through informal channels.

2. The best uses come from users—but they require help to scale.

[Traditionally identification and prioritization of] applications [have] focused primarily on improving the effectiveness and efficiency of known business processes. […] By contrast, our research shows the applications that drive the most value through participatory technologies often aren’t those that management expects. [Management needs to observe what works and then scale it up].

3. What’s in the workflow is what gets used.

Participatory technologies have the highest chance of success when incorporated into a user’s daily workflow. [… As an example] Google is an instructive case to the contrary. It has modified the way work is typically done and has made Web tools relevant to how employees actually do their jobs. The company’s engineers use blogs and wikis as core tools for reporting on the progress of their work. Managers stay abreast of their progress and provide direction by using tools that make it easy to mine data on workflows. Engineers are better able to coordinate work with one another and can request or provide backup help when needed.

4. Appeal to the participants’ egos and needs—not just their wallets.

A more effective approach [for participation] plays to the Web’s ethos and the participants’ desire for recognition: bolstering the reputation of participants in relevant communities, rewarding enthusiasm, or acknowledging the quality and usefulness of contributions.

5. The right solution comes from the right participants.

Targeting users who can create a critical mass for participation as well as add value is another key to success. To select users who will help drive a self-sustaining effort (often enthusiastic early technology adopters who have rich personal networks and will thus share knowledge and exchange ideas), a thoughtful approach is required.

6. Balance the top-down and self-management of risk.

A common reason for failed participation is discomfort with it, or even fear. In some cases, the lack of management control over the self-organizing nature and power of dissent is the issue. In others, it’s the potential repercussions of content—through blogs, social networks, and other venues—that is detrimental to the company. Companies often have difficulty maintaining the right balance of freedom and control.

Prudent managers should work with the legal, HR, and IT security functions to establish reasonable policies. Ultimately, however, companies must recognize that successful participation means engaging in authentic conversations with participants.

The study concludes with a suggestion that “company leaders need to survey their current practices. Once they feel comfortable with some level of controlled disruption, they can begin testing the new participatory tools”.

Be sure to check out the original article in The McKinsey Quarterly.

Posted in web 2.0 | Tagged: | Leave a Comment »

Using Tool To Improve Productivity (1) – JTracert – Runtime Sequence Diagram Generator Tool

Posted by damuchinni on March 11, 2009

In last technique meeting, many people show the interest on can we use some automation tools to improve development/testing productivity. Starting from this message, we will introduce some interesting tools to show how can we use them to facilitate our daily work.
Background and Goals

Recently, many managers and technique leaders all notice that a formal design phase has been ignored by our daily work for pretty long time. On the one hand, none of us likes heavy process which means very long design document and a lot paper work. On the another hand, no any design document (or no formal design phase) actually caused bad design and low quality codes because we don’t really think about the design before implementation.

So, we are trying to find light-wight ways to generate simple design document easily and communicate with others freely.

As we all know, UML sequence is one important URL diagram which can easily describe the detailed process of any operation. However, drawing a sequence diagram manually is a very time-consuming work. In terms of this, JTracert can be the very helpful tool to generate sequence diagram at runtime.
Overview of JTracert

It will generate sequence diagrams directly from your application runtime. you can get it from
Some advantages:

* Understand the code created by your colleagues/partners in a short time
* Rapidly generate documentation for your partners or users.
* Easily investigate what’s happening in large Java applications
* Excellent companion for a common debugger

Detailed Usage

It is very easy to use. JTracert has two jars:

* jTracert.jar is a small javaagent to profile your application
* jTracert-gui.jar is a simple GUI application to display runtime sequence diagram

The following is a simple introduction:

1. Based on your J2EE container, add this line into bat file

set JAVA_OPTIONS=%JAVA_OPTIONS% -DanalyzerOutput=sdEditRtClient -DsdEditHost= -DsdEditPort=60001 -javaagent:jTracert.jar=7007

2. Start container, when you see the following line –
jTracert agent started Waiting for a connection from jTracert GUI on port 7007
3. double click jTracert-gui.jar and connect to server as following –
* Working folder (in which diagram files will be stored)
* Host & port of jTracert agent
* A regular expression for filtering classes to be instrumented and analyzed
4. That’s it. You can see the sequence diagram on jTracert GUI application.

Attached is an example diagram from one application.

Any issue, please let me know.

Posted in Sequence Diagram Generator Tool | Tagged: | 1 Comment »

How to Fix Memory Leaks in Java

Posted by damuchinni on March 11, 2009

Before You Start

Ever heard the story about how Java has “automatic memory management”—you know, the one that someone in marketing upgraded to an epic tale about how you’ll never have to worry about memory leaks ever again? As is often the case, the truth is more complex than the marketing department made it out to be. While it’s true that Java’s garbage collector (GC) helps to eliminate the most common memory leak issues from applications, it is unfortunately still possible to experience memory leaks in Java. However, they happen a lot less often than they used to in the C or C++ days.

Many people believe that black magic and complex tools are required to fix memory leaks. This undeserved reputation is caused by the lack of good explanations of what they are and what to do when you encounter them. But with the proper tools and knowledge to fix memory leaks, they aren’t nearly as intimidating.

In this article we’ll cover everything from memory leak basics to analyzing heap dumps, so—whether you’re an experienced Java developer or encountering Java memory leaks for the first time—you’ll be better prepared to deal with memory leaks by the time you reach the conclusion. We won’t outline a series of steps, like “do ABC with commercial tool XYZ and don’t ask why,” as that approach doesn’t work and implies that remedies are more complex then they really are. Instead, we’ll give you the background information necessary to address memory leaks, with emphasis placed on particular steps you’ll need to execute. Similarly, we’ll assume that you can learn on your own how to use the memory profiler of your choice; what’s missing is an understanding of what the tool is trying to do and why, so that will be the focus of this article.

Java will be used for all examples, so all information in this article directly applies to Java applications running standalone or as a part of J2EE/JEE/Tomcat-based application server. But remember, although our primary focus is on Java, most of the process of diagnosing and fixing memory leaks described herein applies to other languages with garbage collectors. So even if you’re using Ruby, C#, or Python, there should be something for you in this article.
What Are Memory Leaks?

Let’s start by describing how memory leaks happen in Java. Java implements automatic garbage collection (GC), and once you stop using an object you can depend on the garbage collector to collect it. While additional details of the collection process are important when tuning GC performance, for the sole purpose of fixing a memory leak we can safely ignore them.

When is memory eligible for GC? Let’s take a look at an example:


We don’t have to do anything special to make an object eligible for GC—we just eliminate any references to it, and it “magically” disappears and stops using memory. That’s why we say that Java performs “automatic” GC.

Why “eligible” for GC? Because objects are not collected immediately. GC is not instantaneous and comes with some performance impacts. Consequently, Java doesn’t immediately collect every object that is eligible for collection; it typically postpones collection until a more convenient time later on. The way to think about GC in Java is that it’s a “lazy bachelor” that hates taking out the trash and typically postpones the process for some period of time. However, if the trash can begins to overflow, Java immediately takes it out. In other words, if memory becomes scarce, Java immediately runs GC to free memory.

Since we don’t need to do anything special in order to dispose of objects in Java, how do memory leaks happen in Java? Memory leaks occur when a program never stops using an object, thus keeping a permanent reference to it.

Let’s take a look at an example that helps illustrate this point. The following code will cause all available memory in the JVM to be exhausted:


When no more memory is remaining, an OutOfMemoryError alert will be thrown and generate an exception like this:

Exception in thread “main” java.lang.OutOfMemoryError: Java heap space at

In the example above, we continue adding new elements to the list memoryLeakArea without ever removing them. In addition, we keep references to the memoryLeakArea, thereby preventing GC from collecting the list itself. So although there is GC available, it cannot help because we are still using memory. The more time passes the more memory we use, which in effect requires an infinite amount memory for this program to continue running.

This is an example of unbounded memory leak—the longer the program runs, the more memory it takes. So even if the memory size is increased, the application will still run out of memory at a later date.

Posted in Java | Tagged: , | Leave a Comment »

Migrating From Spring dm Server

Posted by damuchinni on March 11, 2009

The easiest way to develop Spring-powered OSGi applications is to use SpringSource Tools (Eclipse plug-in) and SpringSource dm Server combo. They allow rapid development such as MANIFEST.MF validation, convenient deployment and automatic downloading of required (and OSGi-fied) libraries. Later on, when you need to migrate to plain OSGi (just like I do), you can follow this tutorial series.

A month ago I started development of an application with SpringSource dm Server (ssdms). In the middle of the project, concerns arose to deploy it in “plain” OSGi container (namely Equinox). The migration was rocky, so I decided to blog it for the sake of sharing.

First I downloaded the bare bone “Framework” from Eclipse. The “Eclipse Equinox” version (listed topmost) is Framework+stuff, but I didn’t use it since I wanted to build everything from scratch (and it’s stuffed with old Servlet 2.4 and Jetty 5).

The framework is a console, type ss. It will show one active bundle (which is the framework itself). Type close to shutdown.
view source
1.osgi> ss
3.Framework is launched.
4. State Bundle
6.0 ACTIVE org.eclipse.osgi_3.4.0.v20080605-1900

If you want to enable JMX, open eclipse.ini (it’s in if you’re using Mac) and add the following entries:
view source

Run jconsole from Terminal or Command Prompt (assuming JDK/bin in your path) and enter service:jmx:rmi:///jndi/rmi://localhost:6789/jmxrmi in JMX URL. You should be able to see “inside” the framework:

Next step is to fill it with libraries. The easiest way is to copy from ssdms distribution to our Equinox’s /plugins:

* Every jar in /lib EXCEPT:
o Jars started with com.springsource.server
o Jars having slf4j if you want “unified” logging like I do (will explain this later)
o Jars started with org.eclipse.osgi because they may conflict with our OSGi framework
* Every jar in /repository/bundles/ext EXCEPT:
o Jars having slf4j and anything related to any logging framework (commons-logging, Log4J) if you want “unified” logging
o Jars having -sources unless you want to keep the source code
o Jars started with org.springframework.osgi because we will use the ones from Spring Dynamic Modules distribution
* Every jar in /repository/bundles/usr EXCEPT:
o Jars having slf4j and anything related to any logging framework (commons-logging, Log4J) if you want “unified” logging
o Jars having -sources unless you want to keep the source code

What is “unified” logging? Well, you might want to unify your logging facility to be like this:

Essentially everything goes to one sink, easing administration. Anyway the logging deserves its own blog entry so I’ll skip it now. Let’s download Spring Dynamic Modules and copy the following jars from /dist to our Equinox’s /plugins:

* spring-osgi-core-VERSION.jar
* spring-osgi-extender-VERSION.jar
* spring-osgi-io-VERSION.jar
* spring-osgi-web-VERSION.jar
* spring-osgi-web-extender-VERSION.jar

Note: For now, you can use (download and put to /plugins) any logging framework library of your choice. Later on, when you decide to use the unified approach, you must replace them with the SLF4J bridges.

You will definitely want Tomcat and Spring Dynamic Modules to run everytime framework is started. You can go to console and start them manually (the framework remembers last active bundles upon shutdown and will start them next time it’s started), or you can list them in /configuration/config.ini. The latter is prefered since you can “reset” the framework (delete all configuration and cache) and still have the desired bundles run on startup. To do that, put the following entry:
view source
1.osgi.bundles=org.eclipse.equinox.common@2:start, org.eclipse.update.configurator@3:start,
2.catalina.start.osgi-VERSION.jar@3:start, spring-osgi-extender-VERSION.jar@4:start,

Verify our configuration by running the framework again. You should see logs of Tomcat and Spring Dynamic Modules activity. More or less you should see something like this:
view source
01.14:48 Start Thread I o.s.o.w.t.i.Activator – Starting Apache Tomcat/6.0.18 …
02.14:48 Start Thread I o.s.o.w.t.i.Activator – Using default XML configuration bundleresource://3/conf/default-server.xml
03.Mar 11, 2009 2:48:09 PM org.apache.catalina.startup.ClusterRuleSetFactory getClusterRuleSet
04.INFO: Unable to find a cluster rule set in the classpath. Will load the default rule set.
05.14:48 t Dispatcher I o.s.o.e.i.a.ContextLoaderListener – Starting [org.springframework.osgi.extender] bundle v.[1.2.0.m2]
06.Mar 11, 2009 2:48:09 PM org.apache.coyote.http11.Http11AprProtocol init
07.INFO: Initializing Coyote HTTP/1.1 on http-8080
08.Mar 11, 2009 2:48:09 PM org.apache.catalina.startup.Catalina load
09.INFO: Initialization processed in 227 ms
10.Mar 11, 2009 2:48:09 PM org.apache.catalina.core.StandardService start
11.INFO: Starting service Catalina
12.Mar 11, 2009 2:48:09 PM org.apache.catalina.core.StandardEngine start
13.INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
14.Mar 11, 2009 2:48:09 PM org.apache.coyote.http11.Http11AprProtocol start
15.INFO: Starting Coyote HTTP/1.1 on http-8080
16.14:48 Start Thread I o.s.o.w.t.i.Activator – Succesfully started Apache Tomcat/6.0.18 @ Catalina:8080
17.14:48 Start Thread I o.s.o.w.t.i.Activator – Published Apache Tomcat/6.0.18 as an OSGi service
18.14:48 t Dispatcher I o.s.o.e.i.s.ExtenderConfiguration – No custom extender configuration detected; using defaults…
19.14:48 t Dispatcher I o.s.s.t.TimerTaskExecutor – Initializing Timer
20.14:48 t Dispatcher I o.s.s.t.TimerTaskExecutor – Initializing Timer
21.14:48 t Dispatcher I o.s.o.w.e.i.a.WarLoaderListener – Starting [org.springframework.osgi.web.extender] bundle v.[1.2.0.m2]
22.14:48 xtender-Init I o.s.o.w.e.i.a.WarListenerConfiguration – No custom extender configuration detected; using defaults…
23.14:48 xtender-Init I o.s.o.w.d.t.TomcatWarDeployer – No Catalina Service set; looking for one in the OSGi service registry…
24.14:48 xtender-Init I o.s.o.w.d.t.TomcatWarDeployer – Found service Catalina

That’s it for now, later I will write about making EclipseLink JPA to work (dynamically!) and integrating BlazeDS for Flex remoting.

Posted in Springs | Tagged: | Leave a Comment »

Improve your debugging speed with EVars Eclipse plugin

Posted by damuchinni on March 11, 2009

I have been debugging a lot lately which included open source libraries, closed source web-service engine and parts of closed source application server (WebLogic). During this painful debug-fest I felt a strong need for several features missing in Eclipse (NetBeans as well, for that matter) . Debugging closed applications is a pain beyond imagination, even with IDE integrated decompilers, it takes incredible amount of patience and time to debug.

To improve productivity (or prevent burnout), I jotted down a plugin to export/import live variables, filter variables view with a xpath like expressions etc. The plugin, called ‘evars’, features a small expression interpreter (similar to xpath) which can do a wonderful job of filtering variables on current stackframe. It also allows you to export variables to a file and reload them at a later point.

For the first time, I have attempted to create a screencast to explain its usefulness. You may watch it over here [10mb non-streaming, 1275×860].

I have also created a beta release to see if it finds any interest which you can download it from here [JAR ~800kb] and drop it in dropins folder [Eclipse 3.4+].

Posted in IDEs | Tagged: | Leave a Comment »

Thanks For The Weblogic Support Oracle!

Posted by damuchinni on March 11, 2009

I know that it’s a tough thing to move forum contents from one system to another and I know that Oracle and BEA, prior to their buyout by Oracle, had a different forum system than Oracle. I also understand that Oracle would want to move the Weblogic forum traffic to their own forums once the buyout was complete. However why didn’t Oracle keep the BEA forums in place in a read-only format?

Seriously. I’ve been trying to research some Weblogic 9.2 issues I’ve been dealing with and Google results return a lot of hits to the BEA forums. Clicking on one of those links brings you to the Oracle forums….at the top level of the forums. It would appear that those postings were never moved. Again I understand this given the difficulty of moving from one system to another but they should have kept the old system in place for those of us who need to get answers for our Weblogic problems.

The odd thing is that Oracle kept the BEA edocs site in place with the same URL. Why didn’t they do the same thing with the forums?

Posted in weblogic | Tagged: | Leave a Comment »

Correct declaration for a main() method

Posted by damuchinni on March 11, 2009

Correct declaration for a main() method

In the Java language, main() method allows us to run the class as an application. When we execute a class with the Java interpreter, the runtime system starts by calling the class’s main() method. The main() method then calls all the other methods required to run our application.

The main() method must be static, not return a value, and take an array of strings.


public static void main(String[] args) or
public static void main(String args[])

Here public indicates that the main() method can be called by any object.static indicates that the main() method is a class method and void indicates that the main() method has no return value.

main() method can be overloaded

We can create any number of methods called ‘main’ in a class, which take other arguments, are not public and static, or return a value. To be able to run the class, however, there must be one method called main that takes an array of Strings as an argument, and that method must be static, and not return a value. Otherwise we will get a runtime error when you try to execute the class.

Posted in Java | Tagged: | Leave a Comment »