Tuesday, January 22, 2013

Beginning HP-UX for Linux Junkies


I've got the (unfortunate) privilege of doing some tinkering using a HP-UX box. But, as any battle-hardened Linux user would tell you, HP-UX (along with AIX, Solaris and other Unixes) is a different animal. Things may look similar, but lots of commands for simple things are different in parameters and usage. Here's what I learnt during this short stint using HP-UX and hopefully this will be good start for beginners.

Before you proceed

Ensure that the IP address of the HP-UX box in /etc/host file is correct. A simple line like this (10.10.10.10 is an invalid address) will cause a lot of headaches:

#commented as 'evidence'
#10.10.10.10    TEST01

Find out machine architecture:

Run: machinfo

Sample output:

CPU info:
   Intel(R) Itanium 2 9100 series processor (1.59 GHz, 18 MB)
   2 cores, 4 logical processors per socket
   532 MT/s bus, CPU version A1
          Active processor count:
          2 sockets
          4 cores (2 per socket)
          4 logical processors (2 per socket)
          LCPU attribute is disabled

Memory: 16353 MB (15.97 GB)


Firmware info:

   Firmware revision:  04.31
   FP SWA driver revision: 1.18
   IPMI is supported on this system.
   BMC firmware revision: 5.38

Platform info:

   Model:                  "ia64 hp server BL870c"
   Machine ID number:      27f7c389-7d33-11ee-45bb-3c46ec670369
   Machine serial number:  SGH55555RB

OS info:

   Nodename:  TEST01
   Release:   HP-UX B.11.31
   Version:   U (unlimited-user license)
   Machine:   ia64
   ID Number: 0670548873
   vmunix _release_version:
@(#) $Revision: vmunix:    B.11.31_LR FLAVOR=perf


Installing Bash shell

Once you've identified your HP-UX hardware and OS version (mine's ia64 aka Itanium running OS v11.31 aka 11i v3), go to http://hpux.connect.org.uk and search for 'bash'. As of the time of this article, the direct link to the bash download page is http://hpux.connect.org.uk/hppd/hpux/Shells/bash-4.2.039/. The page also shows the run-time dependencies needed. You'll need to download & install the dependencies as well (you can use 'depothelper' to install an application along with its dependencies in one go).

1) Download http://hpux.connect.org.uk/ftp/hpux/Shells/bash-4.2.039/bash-4.2.039-ia64-11.31.depot.gz
2) Transfer file to HP-UX box e.g. /tmp/bash-4.2.039-ia64-11.31.depot.gz
3) Unzip: gunzip /tmp/bash-4.2.039-ia64-11.31.depot.gz
4) Install: swinstall -s /tmp/bash-4.2.039-ia64-11.31.depot bash

By default, all external program executables are installed to /usr/local/bin. So to run: /usr/local/bin/bash

If you see this prompt:

bash-4.2#

Then you have installed bash successfully.

Using X-Windows

HP-UX uses CDE (Common Desktop Environment), so you can use Xming or Cygwin/X and run the following command to bring up the X-Windows login screen:

Xming: Xming -query 129.168.23.22

Cygwin/X: xwin -query 129.168.23.22

There's nothing much to see compared to Linux distros.


Using built-in System Management Homepage web application


By default, HP-UX comes with a nifty web application hosted within its box. This web application is like webmin.

To run: hpsmh autostart

Just point your web browser to https://129.168.23.22:2381/cpqlogin.htm (replace with actual IP of the box).



Useful link: http://www.cyberciti.biz/tips/hp-ux-networking-related-tools-and-commands.html

Wednesday, January 02, 2013

IntelliJ CE for Maven WebApps


IntelliJ Community Edition is a free and good IDE for plain old Java programming, and is also good for Android development. When it comes to enterprise/web development, the Ultimate Edition is the better choice if you can afford it. However, you can also do some simple Java web development using Maven and running your application server outside of IntelliJ. No doubt it's less integrated but you can at least breathe some life exploring more of IntelliJ.

Software used:

  • Oracle JDK 7
  • Maven v3.0.4
  • IntelliJ Community Edition (CE) v12.0.1
  • Apache Tomcat 7


Before starting, ensure that the M2_HOME environment variable has been set to point to your local Maven home folder.

IntelliJ Steps:

  1. Enable on-the-fly compilation. Go to File > Settings > Compiler, check 'Use external build' and 'Make project automatically'.
  2. Ensure the Maven plugin is enabled. Go to File > Settings > Plugins (under IDE Settings), item 'Maven Integration' should be checked. Restart the IDE if needed/prompted.
  3. Create a new project. 
    1. Go to File > New Project..., choose 'Maven Module' (under Java). Set the project location to the desired folder which will house your pom.xml file. Click 'Next' (proceed to create the folder if needed).
    2. Check 'Create from archetype' and select 'maven-archetype-webapp'. Click 'Next'. Click 'Finish'.
  4. At the right side of the IDE, there will be a button for 'Maven Projects'. Click it to bring up the Maven panel. From the panel, you can then run targets e.g. install, clean, package and check the dependencies.
  5. At the right side of the IDE, there will be a button for 'Maven Projects'. Click it to bring up the Maven panel. From the panel, you can then run targets e.g. install, clean, package and check the dependencies.
  6. Point the class files to the web application's WEB-INF/classes folder. Right-click the project root folder, select 'Open Module Settings'. At the 'Paths' tab, under 'Compile output', select/ensure 'Use module compile output path', and change the 'Output Path' to your project's 'src/main/webapp/WEB-INF/classes' folder*.
  7. Add 'maven-dependency-plugin' plugin to copy dependency JARs to WEB-INF/lib folder. Add the following snippet to the pom.xml file (top-level):
    
     
      local
      
       
        
         maven-dependency-plugin
         
          
           install
           
            copy-dependencies
           
           
            ${basedir}/src/main/webapp/WEB-INF/lib
           
          
         
        
       
      
     
    
    
  8. This plugin will instruct Maven to copy all dependency JARs into the 'outputDirectory' path when executing the 'install' task when using profile 'local'. At the Maven panel, check 'local' under Profiles and right-click 'install' under Lifecycles, and select 'Run mavenweb [install]'. After running you should see the junit-3.8.1.jar in the WEB-INF/lib folder.
  9. Add Tomcat webapp config file. This is to specify the Maven webapp folder to be loaded by Tomcat. The simplest:
    
    
  10. Save the contents to the file @ [TOMCAT_HOME]\conf\Catalina\localhost\mavenweb.xml
  11. Run Tomcat. You can use 'catalina start' command under [TOMCAT_HOME]\bin to fire up an instance. Then to test the web app, point your browser to http://127.0.0.1:8080/mavenweb/index.jsp. You should be greeted with a 'Hello World!'.
* I use the 'src' folder so that there's no need to run any Maven 'compile' task and Tomcat can detect a change and reload the webapp. But it's up to personal preference as this way will mean extra care to be taken to cleanup or ignore files for source control check-ins.

Final note
If you need to use a proxy to access the Internet, you can configure Maven to use it by right-clicking the project root folder, select 'Maven' > [Open/Create] settings.xml. Then add the proxy settings e.g.


    
        
            true
            http
            127.0.0.1
            8118
            proxyuser
            somepassword
            www.google.com|*.somewhere.com
        
    

Links:
  • Maven - http://maven.apache.org/download.cgi
  • IntelliJ Community Edition (CE) - http://www.jetbrains.com/idea/
  • http://forum.springsource.org/showthread.php?100694-Maven-dependencies-to-lib-directory
  • http://maven.apache.org/guides/mini/guide-proxies.html