Malaysian airlines website’s server error

How an entire aeroplane, with so much technology at hand, gets vanished will remain a mystery to me. Neither it is clear how the land missile remains unnoticed when fired to an aeroplane. I am no expert in this, but as human I only grieve at the loss. But my today’s post is about smaller tragedy that followed all the MH tragedies.

When my in-laws were flying over, despite the fear, we were looking for tickets with Malaysian Airlines. We have traveled with MH so many times, any other airlines still feels bit foreign to us. While searching for the tickets, we came across this.

Malaysian Airlines website server error

Malaysian Airlines website server error

At this age of internet, a well sought after website like Malaysian airlines *should* bother with proper error pages. But this tragedy was also not handled properly by Malaysian airlines and we came across the horror page.

The amount of technical information that is exposed as part of this is .. slightly scary.
Like now I know, Malaysian airlines (possibly):

  • uses Struts with Spring MVC, with a servlet mapping configuration missing..
  • using Apache Tomcat 6.0.14 – so possibly has security vulnerabilities.
  • From the exposed stack trace, I can see there is abstract factory pattern is in use, and
  • server configuration for needs to be checked out.

Leaving a stacktrace out like this is like doing your laundry in public, and no one wants to see that. 🙂

If you still don’t have a proper error page in place for your site and looking for inspiration, here is my favorite link.
http://alistapart.com/article/perfect404
And more.. http://alistapart.com/article/amoreuseful404

And here, I even googled it for you..

Some of these error pages are so awesome, when I get bit bored, I open them up to get a bit of laugh. I mean it is a bit sad really, but I’m sure you would change your mind if you check this website out for a change..
God! I am getting royal treatment here! **wink** **wink**

Trouble relocating nexus folder?

I got a bit adventurous and decided to install the Nexus in our Dev server. We already have a working version in a virtual environment, but I’ve got my hands on a clean Linux machine and I thought to make best use of it.

I have found this blog post very helpful for a non-Linux native person.
It was very simple to get it started (after I have sorted out some environmental and user right issues).

Once I got it started at port 8081, I wanted to move the folders around. But I didn’t want to set the environment variables, just to make sure my folder structure works..

In order to do this the main file you want to edit is located here,

/[your system folder structure]/nexus-webapp-[version]/conf/wrapper.conf

the wrapper.conf looks like this – just out of the box..

#********************************************************************
# Wrapper Properties
#********************************************************************
# Java Application
wrapper.java.command=java

# Wait a bit longer than default before assuming jvm hasn’t started properly
wrapper.startup.timeout=90

#wrapper.debug=true
#This should be set to the base of your system, which is one folder below the container and nexus folders
#wrapper.working.dir=../../../../

# Java Main class.  This class must implement the WrapperListener interface
#  or guarantee that the WrapperManager class is initialized.  Helper
#  classes are provided to do this for you.  See the Integration section
#  of the documentation for details.
wrapper.java.mainclass=org.codehaus.plexus.classworlds.launcher.Launcher

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
#wrapper.java.classpath.1=../lib/wrapper.jar
#wrapper.java.classpath.2=../lib/my-app-1.0-SNAPSHOT.jar
wrapper.java.classpath.1=../../../lib/*.jar
wrapper.java.classpath.2=../../../conf/

# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=./lib

# Java Additional Parameters
#wrapper.java.additional.1=-d64
#wrapper.java.additional.2=-Dcom.sun.management.jmxremote
#wrapper.java.additional.3=-Dorg.tanukisoftware.wrapper.WrapperManager.mbean=true
wrapper.java.additional.1=-Dbasedir=../../..
wrapper.java.additional.2=-Djava.io.tmpdir=../../../runtime/tmp
wrapper.java.additional.3=-Dsun.net.inetaddr.ttl=3600
#wrapper.java.additional.4=-Xdebug
#wrapper.java.additional.5=-Xnoagent
#wrapper.java.additional.6=-Djava.compiler=NONE
#wrapper.java.additional.7=-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
#wrapper.java.additional.8=-XX:+HeapDumpOnOutOfMemoryError

# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3
#

# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=64
#

# Application parameters.  Add parameters as needed starting from 1
#wrapper.app.parameter.1=com.mycompany.app.App
#

# Make wrapper reload configuration between app restarts (NEXUS-3032)
wrapper.restart.reload_configuration=TRUE
wrapper.on_exit.12=RESTART

#********************************************************************
# Wrapper Logging Properties
#********************************************************************
# Format of output for the console.  (See docs for formats)
wrapper.console.format=PM

# Log Level for console output.  (See docs for log levels)
wrapper.console.loglevel=INFO

# Log file to use for wrapper output logging.
wrapper.logfile=../../../logs/wrapper.log

# Format of output for the log file.  (See docs for formats)
wrapper.logfile.format=LPTM

…..

I didn’t like the idea of having relative paths and leaving all the standard stuff aside, I only wanted to make sure it has got the correct base directory to work with.

So all I did is introduce couple of variable like this at the top :

set.REPO.HOME=/usr/local/your-base-directory-for-nexus/
set.NEXUS.HOME=/usr/local/your-base-directory-for-nexus/nexus
set.NEXUS.PLATFORM=linux-x86-xx

and for all the relative path-ed variable, just update them like this:

….

wrapper.java.additional.1=-Dbasedir=%NEXUS.HOME%
wrapper.java.additional.2=-Djava.io.tmpdir=%NEXUS.HOME%/runtime/tmp

# Log file to use for wrapper output logging.
wrapper.logfile=%NEXUS.HOME%/logs/wrapper.log

If you want to change the folder location, all you need to do is just update your HOME variable to the new path and all will be well. Hope this helpful !

Ant and the Bug

Took the morning out to explore the spring in my machine. After having the Java_home, path set for Tomcat, it was time for ANT.

For some reason the ant was killing my build. Every time I went

C:\Documents and Settings\MyaccountFolder\workspace\springapp > ant
Or,
C:\Documents and Settings\MyaccountFolder\workspace\springapp > ant -verbose build

I would receive detail error that would go like this..

Buildfile: C:\Documents and Settings\MyaccountFolder\workspace\springapp\build.xml

BUILD FAILED
C:\Documents and Settings\MyaccountFolder\workspace\springapp\build.xml:85: C:\Documents and Settings\MyaccountFolder\Tomcat\lib not found.

But my Tomcat was not inside my C:\Documents and Settings\MyaccountFolder
I have even set a TOMCAT_HOME to C:\Tomcat.

Later I was inspecting the build.xml file and build.properties xml. I have copy-pasted it from tutorial.
The only thing I changed was shown here..

# Ant properties for building the springapp
appserver.home=${user.home}/apache-tomcat-6.0.14 /Tomcat
# for Tomcat 5 use $appserver.home}/server/lib
# for Tomcat 6 use $appserver.home}/lib
appserver.lib=${appserver.home}/lib
deploy.path=${appserver.home}/webapps
tomcat.manager.url=http://localhost:8080/manager
tomcat.manager.username=tomcat
tomcat.manager.password=s3cret

I guessed the user.home had something to do with it. so i modified it to be ..

user.home = C:
# Ant properties for building the springapp
appserver.home=${user.home}/Tomcat
# for Tomcat 5 use $appserver.home}/server/lib

Hoping the {user.home} can be overridden .. and on retry with “ant -verbose build” i got:

Override ignored for property “user.home”

This was getting on my nerves.. so I ripped off my decent attitude and hard coded the path..
Voila! that was it!

# Ant properties for building the springapp
appserver.home=C:/Tomcat

======================================

Btw, if you are facing similar issue try this forum post..

http://forums.sun.com/thread.jspa?forumID=45&threadID=5148390

======================================

Today I had a pure blond moment : when asked about DNS I replied ” something to do with database..” my sup said, “What?”, i enforced my reply saying, “Isn’t it something that use to refer to database”? Lolz.. ( shouldn’t have been thinking too much in to Ant)

He was reading about DNS protocol and the new bug that has been posing question whether the entire protocal should be re-written or not. DNS version 2.  Read more about bug..

trim in Javascript!

So, Javascript has no trim option. Its truE!!
So here is two quick workarounds,

var trimmed = str.replace(/^\s+|\s+$/g, ”) ;

Thanks to nicknettleton!

Second one is,

// implementing a trim function for strings in javascript
<script language=”JavaScript” type=”text/javascript”>
<!–
String.prototype.trim = function () {
return this.replace(/^\s*/, “”).replace(/\s*$/, “”);
}var s = new String(” Hello “);
// use it like this
s=s.trim();
alert(“!” + s + “!”);
// end hiding contents –> </script>

Thanks to this site!