c0nnexx10n : C0nnect1ng L1fe w1th Techn010gy

Byte by Byte Impressions on Technology, People and Process !

Archive for the ‘Java’ Category

Installing Apache 2.2.11 with Weblogic 10.3 on Ubuntu 9.04 64 bit

Posted by Vikas Hazrati on Saturday, October 10, 2009

This post takes you through the steps to install Apache 2.2.11 on Ubuntu 9.04 64 bit and make it work with Weblogic 10.3. The post walks through the steps that I followed, the problems that I faced and the solutions ( er..hacks) to get them resolved.

Installing Apache

  • Is simple do

sudo apt-get install apache2

If you want to build it from sources then follow these steps.

  • Once you have installed apache2 then the installation happens at the following locations in Ubuntu

Apache config files are in /etc/apache
Apache log files are in /var/log/apache
Apache libs are in /usr/lib/apache
Other files can be in /usr/share/apache, /var/lib/apache
executables in /usr/sbin apache and apache2ctl

  • Now to start apache execute the following

vhazrati@vhazrati-laptop:/usr/sbin$ sudo apache2ctl start

  • Note that the server is started as a root, else you might get the following error

(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

You should be able to access the default page on http://localhost now and see It Works!

Now, Integrating with Weblogic

Read the rest of this entry »

Posted in Architecture, Java, Weblogic, linux | 1 Comment »

Enabling assertions in Eclipse

Posted by Vikas Hazrati on Wednesday, June 24, 2009

For the entire project

  1. Go to menu Window > Preferences
  2. In the dialogue that appears, select Installed JREs
  3. Select your JRE, and click Edit. A new dialog opens.
  4. Enter -ea under Default VM Arguments
  5. Click Ok to save the change.

For a particular program execution

  1. Open the Run Dialog (this should be an option under the “Run” menu).
  2. Click on the tab, “(x)= Arguments.”
  3. In the field for “VM arguments,” enter -ea to enable assertions.
  4. Click on the “Apply” button.

Posted in Java | Leave a Comment »

Unit Testing Struts 1.2 with StrutsTestCase, EasyMock and Aspects

Posted by Vikas Hazrati on Thursday, June 11, 2009

We have a legacy application and a lot of presentation code is written using Struts 1.2.4. For unit tetsing the action classes we used the following approach.

StrutsTestCase provides both a Mock Object approach and a Cactus approach  to actually run the Struts ActionServlet, allowing you to test your Struts code with or without a running servlet engine. When you want to execute your tests as a part of the continuous integration environment in which all the unit tests should execute without deploying the application to the container.

For the following entry of Struts-config.xml

<action path="/login" type="com.dnbi.simpleaction.LoginAction" name="loginForm" input="/login/login.jsp" scope="request">
			<forward name="success" path="/action/simpleAction" />
			<forward name="failure" path="/failurePath" />
		</action>

and for the following action,


public class LoginAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		ActionErrors errors = new ActionErrors();

		String username = ((LoginForm) form).getUsername();
		String password = ((LoginForm) form).getPassword();

		if ((!username.equals("vikas")) || (!password.equals("pass")))
			errors.add("password", new ActionError("error.password.mismatch"));

		if (!errors.isEmpty()) {
			saveErrors(request, errors);
			return new ActionForward(mapping.getInput());
		}

		HttpSession session = request.getSession();
		session.setAttribute("authentication", username);
		return mapping.findForward("success");

	}

the test would look like this

Read the rest of this entry »

Posted in Better Software, Java, testing | 3 Comments »

Non Functional Requirements: The Usual Suspects

Posted by Vikas Hazrati on Monday, April 20, 2009

In Part-I of this series we looked at what non-functional requirements were and how different people react to non-functional requirements.

nfrs

Ask any team what do we mean by NFRs and most probable answer would be the following and most probably in the order mentioned below

  • Performance
  • Scalability
  • Availability
  • Security
  • Maintainability
  • Reliability

If you come up with a different list on your first pass when asked about NFRs, let me know.

The NFRs which would generally give the biggest bang for your buck are Performance, Scalability, Reliability and Availability. Once you have taken care of these I would recommend looking at the others like Security, maintainability, re-usability, usability etc.

So lets us look at them one by one

Read the rest of this entry »

Posted in Agile, Architecture, Better Software, Java | 1 Comment »

Acceptance Test for Hiring Java Developers

Posted by Vikas Hazrati on Tuesday, February 24, 2009

While researching for my news post on InfoQ, I came across a very interesting acceptance test for Java developers in an extreme programming yahoo group.

The test goes like this


class SeniorDeveloperAcceptanceTest extends TestCase{
Developer candidate;
Collection team;
public void setUp() {
candidate = new Developer();
team = Leirios.getTeam();
}
public void testTechnicalSkills() {
assertTrue(candidate.isJavaExpert());
assertTrue(candidate.canDesignLargeApplication());
assertTrue(candidate.canReduceTechnicalDebt());
assertTrue(candidate.practiceTDD());
}

public void testTeachingSkills() {
assertTrue(candidate.canImproveTeamSkills());
assertTrue(candidate.canArgueAboutAgility());
}

public void testHumanBehavior() {
assertTrue(candidate.canPairProgram());
assertTrue(candidate.canIntegrateWith(team));
assertTrue(candidate.hasPositiveAttitude());
}

public void testMethodologySkills() {
assertTrue(candidate.knowExtremeProgramming());
assertTrue(candidate.canImproveTeamVelocity());
}
}

Read the rest of this entry »

Posted in Agile, Java | Leave a Comment »

JumpStart Your Web Application

Posted by Vikas Hazrati on Wednesday, December 3, 2008

I was planning to start a small hobby project last week. I did not want to build the infrastructure ground up so the best thing was to look at quick enabler tools which would get me started in a jiffy.

I have had a reasonably successful project delivered with Appfuse so this time I thought let me try out something else. That led me to get to 2 other enablers.

RIFE and Able

So this is where I am

Goal: Getting started quickly and getting the infrastructure up so that i can code the business logic.

RIFE: Rife can be thought of as a development library. It can be thought of as a web application API to implement most of the features that common web apps have.
Look at the stack and you would get most of the things that you would desire
rife1
It has Ioc, JDBC Abstraction, support for web services, scheduler, mail queue, out of container testing, authentication, persistence layer etc. etc.

Read the rest of this entry »

Posted in Architecture, Java | 4 Comments »

Java Threads : Basics in 5 minutes

Posted by Vikas Hazrati on Friday, October 31, 2008

The mindmap below summarizes

  • Why we have threads and why they have become the basic unit of scheduling for the OS
  • Why we have multi processor systems now
  • Risks of threads
  • What is object state, and
  • What do we mean by thread safety.

All this meant for quick consumption in 5 minutes …

Read the rest of this entry »

Posted in Architecture, Java | Leave a Comment »

Comparing Products is More Than Analyzing Features, Performance and Cost

Posted by Vikas Hazrati on Saturday, October 18, 2008

We recently had to choose amongst multiple products one product that would suit our needs for processing a specific XML based business reporting format.

We shortlisted 2 products and started comparing them by implementing a prrof of concept in both of them. We analysed them on the basis of

1) Ease of use

2) Feature support

3) Support from the product team

4) Performance of tools

5) Cost

6) Integration with existing applications and products

So where did we make a mistake …

Read the rest of this entry »

Posted in Architecture, General, Java | Leave a Comment »

QuickTip: Accessing External HTTP Resources by Tomcat and Eclipse Behind a Proxy

Posted by Vikas Hazrati on Thursday, October 9, 2008

If you are working in an enterprise environment chances are that you would be accessing this page behind a proxy. Your browser would have a proxy setting like hostname : abc.blah.blher.com and port would be something like 8080.

However if you are sitting behind the proxy and you need you tomcat server to access resources over the internet then these are the VM arguments that the launch configuration should have along with the standard list. Of course, you could also increase the heap size that you want to allocate to tomcat

-Dhttp.proxyHost=battleground.us.abc.com
-Dhttp.proxyPort=8080

and to increase the heap just mention -Xmx1024m

Now for using the proxy settings on Eclipse

Read the rest of this entry »

Posted in General, Java | Leave a Comment »

Base64 : Converting Binary Data to ASCII Text

Posted by Vikas Hazrati on Friday, July 25, 2008

The origin of Base64 may have many stories like it was invented to transfer 8-bit data over systems which could not handle 8 bits.

The uses of Base64 have prevalently been in transferring images as email attachments, transferring non English characters over the internet, converting Binary data to text etc.

My particular need for Base64 came into picture when we were processing a SOAP response. The SOAP response was processed and put into a Map. Now we were required to store this Map into a database CLOB field. Had it been a BLOB I would have pushed the Map in. This is when my friend and fellow colleague Pankaj Misra suggested Base64 encoding to me.

What is Base64?

Read the rest of this entry »

Posted in Java | 2 Comments »