…truth only triumphs…

As you are already aware Java 8 was released a week or so back. Its one of the most awaited released of Java since long. The stand out feature in it is do with movement towards functional programming. I strongly suggest you do a bit of reading on functional programming if you have not done so yet. For your easier consumption i have provided a quick summary of changes in Java 8 here.

Interface Improvements

You can add ‘static’ methods to interfaces.

You can provide default implementation of methods in interfaces with ‘default’ keyword.

You can not provide default implementation for Object class methods in interfaces.

An interface that defines exactly one abstract method is called Functional Interface.

Here is a quick post about a ticky issue that i recently spent some time on and felt good to resolve it. Its about proper packaging and usage of ehache in a spring data based layered application.

Issue
The data-layer of the application is used by two client applications (both running on same linux box) by following means.
1. By a web app running on weblogic using weblogic user.
2. By a batch process running on another jvm as standalone application.
Things worked fine when ‘weblogic’ user is used to run both wls server and the batch process. But when the batch process is executed with another user (say ‘batchuser’ while wls running with ‘weblogic’ user we got the following exception.

Analysis
We are using ehcache and it is configured to use ‘java.io.tmpdir’ (which defaults to /tmp in linux) for the diskstore storage option. Also all the individual cache definitions in ehcache are configured to overflow-to-disk. Since both the applications use the same ehcache.xml file (packaged in the datalayer.jar file) both the applications try to reserve space in /tmp for overflow using same chache names for the entities. When both use same login id they are able to share the files representing the caches but when using different login ids the unix file system does not allow one user to use a file that is created and exclusively locked by different user.

Solution
Solutions for us was easy. We do not need the diskstore facility for now as we only have 4 objects to cache and they are small enough to not bother our memory footprint much. So we removed the diskstore definition from cache and it has worked fine. But the correct solution is to not use the same space for storing caches from two different user processes. One could use ‘user.home’ or something similar for diskstore path. Another way could be to not package the ehcache.xml configuration file in datalayer.jar and let the client supply its own configured file in classpath.

This post is mostly for professionals across the world who seek to travel long term (> 6m?) to UK, more specifically London for employment reasons and always end up asking themselves, how much does it really cost to live there and what kind of life my pay package will offer me there? Answers to both the questions can be summed up in two words ‘It depends’. :)

So one can not provide an answer that fits all individual lifestyles. So you can find thousands of pages on the net talking about the range of prices one have to pay for each expense head. Also i am yet to see one post which gives a detailed break down of all expense heads (at least the compulsory ones) for a regular life there. I attempt that here. Have a look at the table below.

Monthly Expenses

GBP

Remarks

House Rent

750

London subrubs. 2BHK, Zone 4 East

Water + Gas + Electricity

70

Council Tax

100

Tube+Bus Pass

150

Office travel to Central London

Tv License

15

TV+Broadband+Landline

75

Food Expenses

300

Cooking at home 6 days a week

Cellphone+Intl Phone

25

Kids Education

50

Govt School only. Private school expenses 700 GBP/m

Misc

100

Just goes before you realize

Total

1635

This is a sample summary of monthly expenses for a family of 3 (Couple and young child) living in Zone 4 in London subrub area and commuting to central London on work as of early 2013. Apart from these there are few annual expenses one incurs specifically if you are an expatriate. Sample expenses shown below.

Annual Expenses

GBP

Remarks

Annual Vacation

1500

Trip to home country once a year

Shopping & Misc

1000

Personal shopping + Gifts

Health Insurance

400

Saved if provided by Employer.

Total

2900

As i said earlier these are just sample numbers with statistics gathered from very few families staying in same vicinity. Expense heads and actual expenses depend on lot of factors and probably that is the reason why there is no post out there which sums it all in one place. One can take this as an example and do some rough maths to get a picture.

In past during the Waterfall ways of development, before introduction of CI practices, the development teams use to spend time on a phase called Integration phase. The teams use to collect code from various groups/teams and integrate them into one workable code. This was a difficult and error prone task as it involved integration of weeks or months worth of potentially conflicting changes. It was difficult to get it right and almost always lead to delays in project completion via introduction of bugs and uncovering of unforeseen issues too late in the cycle. Continuous Integration process came to being to address these issues.

In simplest form, CI is the process of continuously building software with every change committed into the version control system and providing feedback to appropriate stake holders.

Example CI process flow

The diagram above (not my creation, taken from Dzone, not able to find the link anymore) explains a simple CI process. It starts with developers committing changes into Version Control System (VCS), Subversion in this example. The project needs to create a build script that can be used to build the software. A CI server either keeps checking the VCS for changes or the VCS notify the CI server whenever a change is committed. Upon notification the CI server starts a build using the build script. A feedback mechanism should be put in place (email or message etc) so that a notification is sent to appropriate stakeholders on completion of build process.

CI Stack

The above described simplistic CI process can be extended to automate lot more, for activities that are usually done in software development work and achieve bigger benefits. We discuss here one such extension that we have setup and used in multiple projects and reaped benefits. Include couple of more tools in the above discussed CI setup and call this collectively a CI stack.

Sample CI stack deployment

The diagram above showcases a simple CI Stack that we have setup and used. At the core of it is a CI Server (Jenkins in this case) on which there is a job defined that fetches the latest code from version control system (SVN here) and does a Maven based build. Maven is used as the tool to script the build and manage project dependencies.

The dependency management functionality of Maven needs an artifact repository to resolve various dependency versions. Nexus is used here to maintain and manage a centralized Maven repository and the above build process utilizes nexus to resolve the project dependency libraries. Nexus acts as a proxy to Maven Central repository. If an artifact/version needed by a project is not available locally with Nexus, it connects to Maven Central over internet and downloads the artifact/version and stores it in local file system. For all further requests for the same artifact/version is locally resolved by Nexus.

The end of the build process invokes an automated static code analysis using Sonar. Sonar is a static code analysis tool that integrates popular code analysis tools like Checkstyle, PMD and FindBug into one tool. It also provides exhaustive metric reports based on the results of analysis using the above tools. It also captures code coverage statistics gathered using tools like Cobertura or Emma. These reports are stored in a DB so it can be referred anytime via a pretty web based UI.

The above integrated stack augments the continuous build and test capabilities of a regular CI server with Continuous Inspection capabilities via Sonar and centralized dependency management and release management capabilities using Nexus. The whole stack is hidden behind a HTTP server which acts as a reverse proxy to hide/shield the individual servers from direct access. It also helps simplify the access URLs of various constituent tools of the stack using a unified IP: port address.

This stack can be extended to add further capabilities. One such thing is web based code review using Trac tool. This can be integrated into individual developer IDEs as well while the web based reports can help QA personnel to extract necessary metrics.

The Cisco VPN client software provides a GUI based tool to setup and connect to a vpn network using various connection methodologies. Connection configurations to a particular network can be stored as a profile.

My team needed to do vpn connect and disconnect quite a few times during the day. The operation involved multiple monotonous clicks to connect or disconnect. So it called for one click automated process.

Similarly we had Continuous Integration server that needed to connect over vpn to get code from source control management system. The server could not be put on a permanent vpn connection as doing so made the server inaccessible to local network. The server should be available on local network most of the time but can connect to vpn for a brief period of time during a job execution to checkout code. This needed a silent and automated way of connection and disconnection from vpn.

Thankfully the vpn client software does provide a command line interface though the accompanying documentation leaves lot to be desired. So a bit of playing around was needed to get it working.

Here are the windows scripts that can be used to automate the connect/disconnect task. I am using Cisco VPN client version 5.0.x.

The functions of the files are self explanatory. But still to be foolproof,
vpn-connect.bat – connects to the vpn
vpn-disconnect.bat – disconnects from vpn
vpn-input.txt – used by vpn-connect.bat to silent the warning pop up (if any) thrown during connection operation

To make the scripts work, one would need to create a connection profile using the vpnclient user interface, copy the files into a folder and then change the following,

You can change the error codes to values that suits your automation environment. I have explicitely set the values to either 0 or 1 as the scripts are used by Jenkins (on the Continuous Integration server) and it fails the build if the batch execution returns a non-zero error level. The vpn client returns 200 on successful connection.

Once these setup are done you can just double click on vpn-connect.bat to get connected to vpn and do the same on vpn-disconnect.bat for disconnection; as simple as that. Enjoy. :)

I intend to report this issue with WebLogic Server (WLS hereafter) which has taken quite a bit of my peace and sleep over last week or so. Obviously i did try to find help on internet with all sorts of keyword search combinations but all in vein, except for one which looked to point to a Oracle bug report url but broken one. :(

Infrastructure:
I have a clustered WLS setup hosting three applications connecting to Oracle database while Http requestes are load balanced between the cluster nodes via an iPlanet web sever.

physical machines – two solaris hardware [say m1, m2]

cluster – two clusters [c1, c2] each with two WLS instances. Each node of the cluster resides on different machine, ie c1 is spread accross m1 & m2 and so is c2.

applications – three jee EAR archives [app1, app2, app3] with app1 deployed on c1, app2 & app3 deployed on c2. Applications are deployed on all nodes of a cluster. These archives are versioned applications, meaning they define Weblogic-Application-Version property in manifest.mf file of the EAR.

Issue:
Ocassionally i do rolling restart of the clusters, ie restart one node while other is running and then do the same with other node, to ensure availability. However, during the period when one node in the cluster is down, the JNDI tree in the other node seems to get messed up. All EJB accesses by the application fail with javax.naming.NameNotFoundException. The JNDI tree however comes back to normal state when both nodes in the cluster are up and running. Also i noticed only the EJB resources [the stubs and homes] seem to be in error state while the JMS/JDBC resources are intact. See the exception trace below.

Clusters use multicast addresses with almost all default settings. I did change to use Oracle recommended Unicast messaging but in vein.

All ejbs are SLSB written in 2.1 syntax but deployed with 3.0 deployment descriptors. Tried to force clustered deployment for all ejbs using tags even though it is default. Didnt solve the problem.

Interestingly it works like a charm with wls 8.1 servers with code compiled in jdk 1.4. I just migrated my code to deploy on wls 10.3 with code compiled in jdk 6 and ejbs deployed with 3.0 deployer schemas.

I have ensured that only one [and identical] version of each application is deployed in each node in cluster. So there is no reason to suspect confliciting versions.

If a user has active session before one node is restarted and the same node was serving the user request, wls is able to failover the subsequent request from the user to active node. However, if the logs out and re-login, it failes to find the EJBs.

SOLUTION:
Remove the versioned redployment. Do not version your application ear archives. It surprises me because it all works fine with wls 8.1, jdk 1.4 – not sure why it doesnt work with just wls/jdk upgrades while all else remaining same.

I have faced intermittent issues with this feature of weblogic [versioned application redployment] for a while. And WLS documentation also suggests to use this feature with caution. I would be interested to know what caused the problem i faced though i am a bit relaxed now – that i know how to avoid the problem irrespective of my likings. :)