Archive for July, 2007

Setting up trusted domains in Weblogic

The recent project I’m doing required separate deployments in Weblogic 8 & 9. One of the projects require access JNDI to the other server to lookup a JMS Queue. Oddly when deployed to a Tomcat + Weblogic 8 combo, everything worked fine. However, when deployed to a Weblogic 8 + Weblogic 9 combo, the following error message appeared during Spring initialization:

java.lang.SecurityException: [Security:090398]Invalid Subject: XXXXX

Searching the web finally led me to this page. True enough after setting both Weblogic to trust each other, the problem went away. To trick is to set both credentials on both domains to be identical. Here’s how to do it in Weblogic 8 (xeroxed from the WL8 docs):

# Expand the Domains node (for example, Examples).
# Click the View Domain-Wide Security Settings link on the Domain–>General page.
# Select the Security Configuration–>Advanced tab.
# Uncheck the Enable Generated Credential attribute.
# Enter a password for the domain in the Credential text field. Choose the password carefully. BEA Systems recommends using a combination of upper and lower case letters and numbers.
# Confirm the password by entering it in the Confirm Credential text field.
# Click Apply.

On Weblogic 9, it’s not too different. When both of the domains have been set to use the same credentials, the error message goes way.

Pre-UAT Realizations

OK, straight up I’ll admit I’m on rant mode. I’m tired, overworked and probably a little bit stressed. But that won’t stop me from blogging. Here’s some context - I’ve been very busy with a project lately, more than usual, because the roll-out date has passed but instead of wrapping up and celebrating, we’re just starting User Acceptance Tests. Bummer. But enough of that. What I like to share is the (painful) experience of a team lead, just pre-UAT.

  • Integration is painful. OK, I know, this really isn’t some secret but no matter how much I try to minimize this, it never fails to surprise me. I’ve had problems with Weblogic, Oracle, XA JDBC drivers, even software libraries (log4j and MyFaces if you must know). I made sure we had a running build on local machines but made the ultimate mistake of not using the same application servers. Well actually, we just ran an oh-so popular Servlet container on dev machines (all under-powered laptops btw) while the production server was running Weblogic 9. I was totally caught off-guard when doing integration work to our staging server which also ran Weblogic. I’ll save you the horror stories though. Safe to say that next time, yours truly will start integrating work ASAP as in the 1st week of coding on an environment mirroring the production’s. It’s better to have a continuous integration than during a pre-SIT/UAT phase.
  • Deployment & packaging is painful. The problem not only lies in figuring out where to place the compiled source, libraries and configuration files but also what type of archive to place them in. Oh, I’ve had the joy of deploying 1 EAR, which contained a WAR, an EJB (with a few Message Drive Beans in it) and a core application library which all needed to share logging and Spring configuration as well a plethora of 3rd party libraries. Absolutely lovely. I spent a whole weekend figuring out where to put what. I have to admit that in the end it was pretty simple but it was a terrible experience trying to start.
  • Logging is absolutely crucial, and yeah, it’s painful to get it right. I don’t know if it’s just me not understanding log4j or a configuration problem but I seem to never get it right. The requirement is pretty simple, have an catch-all log file, a catch-all ERROR log file, and some other log files for important components. But I somehow ended up having jumbled up entries in the ERROR log file. I’ve also had issues with configuration but that was solved when I repackaged my EAR. Some errors were also solved by making sure the correct lo4j logger instance was being obtained (copy-paste style programming being the culprit here). Also, I’m always surprised at how so many junior developers think of logging as an after-thought. This coupled with a terrible way of handling Exceptions (which btw is why I’m still up so late), ends up in totally meaningless logging. It’s too common to see too many throws and watering down of Exceptions until all the context information have been lost. So now I have log files which has some mixed up entries, with meaningless information. Great.
  • A solid, extensible framework is very crucial to development. Even though I was overseeing just one project, the project itself is split into two smaller projects. A front-end project which is a web based project which ran on JSF-Hibernate-Spring. The other was the back-end project which was a lot of Java classes, a couple of MDBs, some simple servlets doing batch processing. For persistence it used Hibernate as well. The front-end project was pretty well structured, a framework was thoroughly discussed and agreed upon among all the developers before work began. Build files, directory, packaging, architecture, everything under the sun was laid out. Sure we had issues along the way but overall development work was smooth. The back-end project however, was total chaos. An all too often and common excuse given by the person in charge was “I’ll do this later, have to figure out this programming problem first”. Two weeks before the project goes rolls out, I took a look at the codes and almost had a heart attack. The whole thing was thrown away the next working day. I was pretty sure that had that project gone into production with that set of codes, it wouldn’t survive one day. And it wouldn’t be maintainable. Actually, now I’m pretty sure it will also never get deployed in the first place because no one can figure out how to package it short of throwing all the junk together and hoping it’d some how stick together. Now, 2 weeks later (after long hours and working weekends), the back-end project is 95% up and running. The initial development time took 5 weeks. I had a few excellent pair of hands helping but the same pair of hands struggled with the earlier version of the project. I like to think that the clean-cut architecture as well as the easy deployment (which facilitates fast testing) helped shortened coding time.

Another discovery worth mentioning is that Spring is absolutely the most brilliant piece of work I’ve ever seen in the sea of frameworks. Anyone that does any sort of large Java project should seriously check it out. You will not regret it. The best thing about Spring is that it actually enforces a style of coding that follows best practices (very layered architecture for example Services and DAOs can be clearly defined). It also provides a very easy way to handle cross-cutting concerns via AOP. I’ve managed to implement a very smart way of doing auditing, one which requires very little coding on the audited objects by using AOP. The non-intrusive nature of AOP is important here because relying on developers to do auditing will usually result in no auditing at all. Last but not least, Spring can be very useful because it provides utility classes for almost all the other frameworks or libraries - Quartz for scheduling, JMS for distributed messaging, JNDI templates, Hibernate templates, etc. And best thing of all is that learning how to configure these things takes 1 to 2 days at most. Usually you’ll get something running in a few hours. But I think the ultimate satisfaction from using Spring is the beautiful code that results from it. You’re rid of all the boiler plate codes and everything is so configurable with zero code change. Heck I moved from a local JDBC datasource to a JNDI without making a single code change. I enforced Transactions without code change. Then I enforced distributed Transactions via JTA without code change. I put in a scheduler, again, without code change. Well, you get my point. Magic? Nope, just Spring ;-) I truly believe that because I decided to use Spring, the current project I’m working on has been developed much faster, is much more robust and will be easier to extend and maintain in the future. By the way, there’s Spring for .NET as well.

OK, that’s it, time to get some shut-eye.

Retrieving CPU & Memory Information in Solaris

Here’s a nifty way to get some information regarding CPU and memory in Solaris:

  • psrinfo -v
  • prtconf -v | grep Memory

How GPS saved me an hour’s journey to work

I drive from Kepong to Subang Hi-Tech park daily to work. Today was different though because I had to drive my girl friend to KL Sentral which meant I had to take an unfamiliar route to Subang Hi-Tech. To make matters worse, there was heavy traffic all the way, on both directions. Lucky me I had my trusty phone with me so I fired up its GPS. Once it had a lock on my location, I proceeded to plot a route from KL Sentral to Subang Hi-Tech. Guess what? It plotted a course that led straight to a freeway which led straight to Subang Hi-Tech. Even with slow moving traffic (the norm for Malaysia freeways), it took me just 1/2 to reach work. Had I gone back the way I came, it would take 1/2 hour just for me to get back to my place, then another 40 minutes of drive to work.

So I guess what I’m trying to say is that a GPS device can come in really handy at times. This is very true if you’re someone that travels frequently or is currently staying in large cities. If meddling with smarphones and PDAs ain’t your cup of kopi, then have a look at standalone GPS devices that you can put in your car or the recent Nokia N95 or 6110 Navigator.

More Computing Power Is Better

Dual core CPUs, gigs of RAM and tons of hard drive space. What a sweet combination. Even working from home I can run Weblogic 9.1 on a 64-bit Solaris 10 and Oracle. All while keeping my native OS (that would be Windows XP Pro) chugging at a healthy pace. The Solaris 10 was running on VMWare Server while Oracle ran natively in Windows. To allow both my native and virtual OS to run smoothly, I allocated 1GB of RAM to each. This allowed Windows XP to function well, provided not too many applications open. I can manage to run Oracle, Firefox, VMWare, VNC viewer, Filezilla client and Trillian. Not bad, eh? P/S, I actually run the heavy weight software because I was testing out an environment that I need to use for work, not because it was fun (not that it wasn’t ;))

I also remote access my work laptop to build since my source codes are there. This also means I don’t need to run Eclipse on my desktop which would have definitely brought it to its knees considering Eclipse would need an extra 250~300MBs of RAM. For accessing my laptop, I use Ultra VNC because of the love-able file-transfer feature (I used to run a FTP server service on the desktop). By the way, Ultra VNC also offers a whole lot of other features, but the other two that I like most other than the file transfer was the mirror driver and ClearType support. The mirror driver allows high performance display giving the effect of a local desktop due to the fast updates of the display. ClearType support is well, self-explanatory. Ever noticed that Remote Desktop and other VNC clients doesn’t render ClearType fonts which makes everything look fugly on LCDs.

If all of this sounds like I’m doing some fancy acrobatics with the Alt-Tab key combo, relax. I’m not, thanks to my dual-screen 19″ LCDs (a pair of Acer AL1917/1916 if you must know). With a combined screen space of 2880×900, I avoid stressing my fingers and my keyboard by not having to frequently swap between applications. Uber cool. Which reminds me, here’s a screen shot of my desktop at work.


Click for full size image
Yup, the display is pretty sweet. Quality is great too because I’m running these off a 7900GS which sports dual-DVIs. I’ve seen VGA port used on a relatively large LCD - it looked horrible with ghosting all over the place. Yuck. I imagine if I had to use that kind of display while staring at source codes (that means lots and lots of reading), I’ll be getting a pair of glasses way too soon.

iPhone VS N95

I’m sure most of the people actively surfing the Net has come across this before, but I’m gonna post them here anyway because I just discovered these yesterday night and it was hilarious as hell. No offense to Apple fanboy or girls but everything mentioned here is unfortunately true. But that’s not the point, the point is, these are funny. Do watch the videos.

Symbian-Guru.com: N95 vs. iPhone - Going to China?
Symbian-Guru.com: N95 vs. iPhone - Ringtone
Symbian-Guru.com: N95 vs. iPhone - MMS
Symbian-Guru.com: N95 vs. iPhone - Camera
Symbian-Guru.com: N95 vs. iPhone - Internet