Saturday, June 8, 2013

Maven package all jar dependencies into one jar

Many times you would have wanted to combine your main class code along with all dependent project jars into single jar which helps in easy distribution of your project. You can acheive the same using below maven plugin.

To generate the assembled jar, execute below command
  • mvn assembly:assembly -DdescriptorId=jar-with-dependencies
If you want to do this as part of regular maven package command, then include below execution tag after configuration tag  in above pom
      <id>make-assembly</id> <!-- this is used for inheritance merges -->
      <phase>package</phase> <!-- bind to the packaging phase -->

Courtesy :

Friday, September 14, 2012

Linux/Unix commands and utils

I will be putting all the simple unix helpful commands and utils over here. Starting with only couple of commands. Will be updating this on regular basis.
  • Calculating frequency of data in UNIX
    • Calculating frequency of some data in a plain text file. For example if the file has data in each line like as in this file. Then program should print frequency of numbers as output as given in this file.
    • awk '{x[$1] += 1}END{ for (entry in x) {print entry "-" x[entry]} }' 1.txt
    • Note that this can be applied to applied to any arbitrary pipe output also by appropriately select the data column number ($1 or $2 etc.)
  • Get range of lines from a file or output
    • The below command prints 2nd to 5th line of 1.txt file
      • awk 'NR>=2 && NR<=5 {print $1}' 1.txt
  • To know your IP from unix command line
    •  wget -qO-

Saturday, September 1, 2012

Configure WPA wireless network interface in ubuntu through command line

We will go through steps to configure wireless network interface having WPA security through command line in ubuntu

  • Ensure that wpa_supplicant package is installed. If not try to get it by running
    •   sudo apt-get install wpasupplicant
  • Open your /etc/networking/interfaces (with sudo) file and add below two lines
    auto wlan0
    iface wlan0 inet dhcp
  • reboot the system (Dont worry if the startup says all network are not started. We will set it up)
  • Now type "wpa_supplicant -h" to get list of driver names. Observe the section "drivers:" in the output. Watch out for driver text like "Linux Wireless extension". Generally it is wext
  • Now we will create a configuration file for wpa. Create one in /etc/wpa_supplicant.conf with below content

  • Now we will generate the text required for the WPA authentication. Type below command where NetworkSSID is your wireless network name
    • wpa_passphrase "NetworkSSID"
  • Enter your WPA passphrase when it prompts
  • Now it will generate a ouput similar to below

  • Copy the above text to the end of /etc/wpa_supplicant.conf and also add scan_ssid, proto & key_mgmt keys as below (#psk can be removed as it's just a comment)
    • network={
  • Now type below command to test all the configurations done till now. In below command wlan0 is the  interface name we defined in /etc/networking/interfaces and wext is your wireless driver name
    •   sudo wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
  • You should see below text in output
    •  WPA: Key negotiation completed with 
  • The above output confirms that all steps are correct till now
  • Now we just need to tell ubuntu to use this wpa_supplicant configuration for this particular wireless device. For that, add two lines in /etc/networking/interfaces immediately after (iface wlan0 inet dhc) line which we added in the beginning. So it would look like (combined)
    • auto wlan0
      iface wlan0 inet dhcp
      wpa-driver wext
      wpa-conf /etc/wpa_supplicant.conf
  • Reboot the system

That's it. Now you should be able to access wifi from your ubuntu machine

Monday, November 8, 2010

Spoofing server that your browsing from mobile

Many websites prepare special trimmed down websites for mobile clients. Only functionally relevant content is displayed in these trimmed down pages. So if bandwidth is precious for you OR if you just want to get your things done quickly, you can use User Agent Switcher firefox add-on where you can set that you are browsing from mobile

After installing the addon, go to Tools -> Default User Agent -> Select any agent name which belongs to mobile.. like IPhone 3.0
Now go ahead and browse any site which has custom pages for mobile. You will observe that only trimmed down content is being displayed.

Test 1
Open in firefox browser without activating the above add-on. You will see below page

but once you use the above IPhone agent, it will display the below trimmed down page in firefox browser

If you make a google search in firefox without the addon, it will display the results along with Google Ads. But if you use the above add-on with IPhone as user agent, it will only display search results in firefox (WITHOUT Google ads)

The server identifies the client based on User-Agent HTTP request header. So this add-on just replaces the header value from firefox to any selected value.

Custom Mobile Headers
You can also use any custom header. To add a custom header, Tools -> Default User Agent -> Edit User Agents -> New. You can get list of all user agent headers from here.

Please note that the above content is provided only for information purpose.

Friday, June 25, 2010

Invoke ANT targets programmatically using java

You can invoke ant targets programmatically with java using below code. You need to be sure that the jar files inside ANT_HOME\lib are included in project.



public class Test {
public static void runAnt(){
File buildFile = new File("build.xml");
System.out.println("ERROR :: File "+buildFile.getAbsolutePath()+" does not exist");
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
public static void main(String... args){

Wednesday, June 23, 2010

Build and Deploy SOA Composites using ANT targets

The steps to build and deploy a SOA composite using an ANT target of build.xml is demonstrated in the current post.

1. Download and build.xml.
2. Place the above two files inside build or deploy folder of the composite project. i.e. if HelloWorldProject is the directory of the composite project, then these files should be located inside HelloWorldProject/build or HelloWorldProject/deploy
3. Change the property values of file as per your scenario. The documentation above each property should be self explanatory.
4. Ensure that you have ANT has been installed and paths have been property set in environment. You can find more details of installing ANT here
5. Now open the command promt and change to the directory where the above two downloaded files have been placed.
6. Use the three targets defined in build.xml as explained below ::
- If you require only to build the composite SAR, then type "ant compile-package"
- If you already have the jar and want to deploy onto SOA server, then type "ant deploy"
- If you want to both build and deploy, then type "ant buildAndDeploy" or just typing ant should suffice as buildAndDeploy has been given as the default target in build.xml

Monday, April 26, 2010

Correlation Sets tutorial in SOA 11g using Oracle JDeveloper

Usage of Co-relations sets in SOA 11g has been demonstrated in this blog. Correlation sets are typically used when you need to contact with an already running BPEL instance.

Sample use case of co-relation sets ::
In our current application we need to expose a BPEL service which will take Employee ID as input and asynchronsoulsy calls back another method returning the Name of the given Employee ID.

Now once it receives the Employee ID, it waits on an receive activity to receive the Employee name for the given employee ID. Through a separate service call, we will provide the details of Employee name for the given employee id to the above BPEL instance. Once the BPEL instance receives the name, it proceeds further and callsback the method to return the employee name.

Here the correlation sets are required because when the second service is invoked to provide the details of the employee name, it needs to know to which BPEL instance the details should be provided. This is tracked internally using the correlation sets by setting EmployeeID as the property in the correlation set.

The series of images below demonstrate the development of this sample applicaiton. The completed sample of this tutorial is available here. All the below images are annotated with proper explanation. So the slides are self explanatory.

Slide Show ::
You can access the slide show of images here.