How to generate Weblogic core dump in Solaris

This is what I did recently to generate core dump of Weblogic server running in Solaris box. Had to spend sometime to figure it out where the dump is being generated.

Here are the steps I followed:

[1] Run ps -ef | grep java command.
[2] Identify the process id of the Weblogic process [ Make sure only one Weblogic process is running so that it’s easy to identify ].
[3] Run the command kill -3 process_id
[4] Assuming that the Weblogic server is started using nohup ./ & command, the core dump will be appended to nohup.out file.
[5] You can check this by doing less and Shift + F on nohup.out file.

How to pre-complie JSPs in Weblogic

This is one of the techniques I implemented in my last project, among others, to improve response time of JSPs in a Struts 2 based web application.

We know that, in any J2EE web application, the page load time is relatively high when we access the page for the first time because the container has to compile the JSP before presenting to the user. This is a performance bottleneck and gives the perception to the users that the system is slow.

To prevent this, we can precompile JSPs before deploying them in the server. WebLogic server offers two ways to pre-compile JSPs.

[1] Declarative Method
[2] Programmatic Method

[1] Declarative Method.

How to implement:

Add the following configuration to WEB-INF/weblogic.xml







Easy to implement


Precompilation happens at the time of deployment. This is a major disadvantage because:

(a) If any compilation error occurs, deployment will be halted at the point where the error occurred.
(b)The time taken for deployment will be very high if an application has more number of JSPs.
(c) Pre-compilation occurs every time the application is deployed, increasing the time of deployment.

[2] Programmatic Method.

Declarative method is not used for practical purposes for the disadvantages it has compared to its advantages.

Most efficient method for JSP precompilation is the programmatic method. This method eliminates the biggest disadvantage of declarative method – precompiling at deployment phase- and moves the precompilation process to development phase.

How to implement:

WebLogic provides a tool called weblogic.appc for precompiling JSPs.

Add the following ant target to the build.xml file

<target name="jspcompile">

<java classname="weblogic.appc" fork="yes">

<classpath path="${env.WL_HOME}\server\lib\weblogic.jar;${env.JAVA_HOME}\lib\tools.jar"/>

<arg line="-verbose -classpath '${}\requiredLibs.jar' '${}\demoApplication.war'" />



Some points to note:

(a) This task should execute after the task which creates WAR file because weblogic.appc expects a WAR file containing JSPs.
(b) Environment variables WL_HOME and JAVA_HOME should be set for ant to access environment variables using env.WL_HOME and env.JAVA_HOME
(c) is the project’s intermediate build directory where WAR file and any other JAR files etc are created.
(d) requiredLibs.jar is the library containing any classes used by JSPs. Multiple library files can be added as comma separated list.
(e) demoApplication.war is the WAR file where application’s JSPs reside.
(f) If you have spaces in , then use single quote(‘) as shown above. Otherwise ‘ are not required.


(a) This method moves the precompilation to development phase so that any compilation errors are identified and corrected much before deployment.

(b) This method allows us to compile once deploy as many times as we want.

(c) This method reduced the deployment time significantly because precompilation is moved to development phase.




How to read files from CLASSPATH in Java

This is one learning from my previous project in 2009.

The most platform-independent and flexible way in Java to load resources such as files is to read the resource from CLASSPATH. This way, as long as the resource’s location is added to CLASSPATH, the resource can be anywhere on the disk.

Java provides a method named getResourceAsStream() for this purpose. This method is present in both Class and ClassLoader classes. There are very subtle differences between these two methods, which if not understood properly, will lead to confusion.

Using ClassLoader.getResourceAsStream(),

While using ClassLoader.getResourceAsStream() method, the name of the resource should not be preceded with leading slash (/) in any circumstances. This is because from ClassLoader all paths are already absolute and there is no context from which they could be relative. Therefore the question of whether or not to use leading slash (/) should not arise. If you add leading slash in front of the resource name, InputStream will always be null.

To use ClassLoader.getResourceAsStream(),

[1] In CLASSPATH add the directory where someFile.txt resides.

[2] Use the following code to read the resource.

InputStream in = this.getClass().getClassLoader().getResourceAsStream(“SomeFile.txt”);

Using Class.getResourceAsStream(),

(a) If the resource and the Java class which is reading the resource are in the same directory then there is no need to use a leading slash (/). You can directly use the following line of code to read the resource.

InputStream in = this.getClass().getResourceAsStream(“SomeFile.txt”);

(b) If the resource and the Java class which is reading the resource are in different directories then you have to use a leading slash (/).

[1] In CLASSPATH add the directory where someFile.txt resides.

[2] Use the following code to read the resource.

InputStream in = this.getClass().getResourceAsStream(“/SomeFile.txt”);

Important Note:

When we are using a managed environment i.e. in case of application servers, CLASSPATH entry has to be made in the server’s start up script. For example in WebLogic, CLASSPATH entry has to be appended to the one already present in startWebLogic.cmd ( in Unix environments) in DOMAIN_HOME\bin directory.



How to pause cmd window incase of any exceptions.

Last year I had to write a small piece of java code to launch another application using one of the available ports between certain range. I wrote the code and saved the command to launch the java class in batch file so that when the user double clicks it, java class will launch the application.

There is a small catch here. The cmd window does not pause irrespective of how the program runs. If the program runs successfully, then fine. But how will the user know in case of any exceptions? So we need to add one line in the batch script at the end to pause the cmd window in case of any exceptions so that the user will get the chance to see what the exception is. The following line is what needs to be added so that the cmd window pauses in case of exceptions:


iPhone 4. A dream, realized.

14 October 2010
Level 15, 92 Albert Street
Auckland, New Zealand

This is the location where a dream I have been dreaming from 2007 January got realized. I have my dream gadget in my hand. In fact my dream has been transcended. I just dreamt about iPhone and I got iPhone 4. I never thought I can put my hands on my own iPhone so early. I just love this device. It is a great companion. I can talk, chat , tweet, blog, surf, capture, read my PDF collection and do lot more stuff from this 3.5″ screen awesome device in style. iPhone will definitely enrich my life and help me become better person than I am now. That’s why I just love my iPhone.

Thanks Jobs for creating this masterpiece. Thanks Infosys for enabling me to access and afford this great piece of engineering.

How to induce delay in Loadrunner Java Vuser script

I had to send two xml messages to a JMS queue with slight delay between them. Since I am writing a Java Vuser script, I wasted no time in choosing Thread.sleep( milli sec) function. This worked fine in Vugen so I was sure. But during the execution of Scenario in Load Controller, I observed that the expected output of the transaction is broken and the transaction is failed.

Upon investigation I found that the two messages are not going to the queue in the order we expected. The second message is going early causing the transaction to fail. This is because the Controller is NOT inducing the delay I mentioned in Thread.sleep function. So the correct function to use is lr.think_time(sec). This function causes the Controller to actually wait for the specified number of seconds.

Just this 1 line of code resulted in wastage of 2 person days! But again, this can be learned only by experience.