Aurora and Sol

Those are the names people: mark em down. Flexamp is on its way out :). I kinda want the player name to be independent of the technology behind it (I am following an industry norm here. There arent and C++MediaPlayers or JavaAmp 😛 ). While these names may or may not stick, these are the package names of the Flex Project and the J2EE Project on my Eclipse application so they will always be reflected in the source files.
I am fairly far ahead on the clientside implementation of the player but am just about starting the J2EE part. I havent mucked around with J2EE as much although I do come from a Java background as such. Desktop Java has much fewer rules to adehere to. The first step in J2EE is the biggest one and understanding the structure of a J2EE app does take some serious reading.
Of course there is a leap from the book to the server ;).
So here is the story of day 1 of Sol development.

Step 0 – Choose Eclipse:
I do all my programming on Eclipse and love it. Ever since the ASDT plugin came out, Eclipse has been my standard development environment. Its well integraded with CVS and SVN and allows quick text searches which makes life a lot easier. And developing Flash and Java on the same IDE is veeeery convinient. The web tools project is something I am just getting used to and while I have heard seasoned Java developers complain about certain features, my own experience has been fairly good. So armed with Google, I created the Sol project.

Step 1 – Get your J2EE app container + MySQL database:
My www host runs Tomcat 5.0.27 so thats what I run as well. I also downloaded the appropriate MySQL version

Step-2 – Create the Dynamic Web Application Project:
This is a project template that I think came with the web tools plugin on Eclipse. Once you create a new Dynamic Web Project, Eclipse will create the WEB-INF, META-INF, classes and lib directories as per the J2EE spec(A typical j2ee webapp should look like this) in a folder called WebContent. That folder can go as is as a webapp in a container (although typically you would deploy it as a web archive (war) file).

Step 3 – Include the jstl taglibs in your container:
Since I will be using the Java Standard Taglibs, I downloaded the jars from the Apache site. Include these taglibs in either your application’s lib folder or, preferably, in your container’s common lib directory (TOMCAT_HOME/ROOT/common/lib/) which would make them visible to all the webapps.

Step 4 – Create your basic JSP
Since the goal of this pass is to verify that my installation is correct, I wrote the simplest JSP file. You can download it from here.

Step 5 – Run the JSP from within Eclipse:
Make sure that the Tomcat Engine isnt running and then right click on the project and choose Run As … > Run on the server. Update the files if prompted and point to the installation directory of the Tomcat server when prompted to choose the local server. As the server starts up, the server logs appear in the Console window. Eclipse will then launch the built in browser and point it to the application root. Click on the JSP page and ensure that it works.

Possible issue: I have no idea why this was happening but even though my JAVA_HOME environment variable was pointed correctly to the JDK, Tomcat could still not find the javac tool to compile my JSP. On a thread I found the solution to put the tools.jar into the TOMCAT_HOME/common/lib directory. That worked.

Cheers.

Https on Apache Tomcat 5.5

I tried to play around with Flex Data Services today. So I downloaded the package and went through the install. Now since I already have an instance of Apache Tomcat 5.5 running on my laptop I was less than inclined to install JRun. So I installed the non-JRun package and deployed the FDS WARs. I ran the the collaborative dashboard example and things looked good. The other application I had been eyeing for a while was the NoteTag example application written by Adobe. For the uninitiated, NoteTag is a collaborative note taking application. The coolest part of NoteTag is that it doesnt have a backend database but rather uses Blogger, TypePad and Del.icio.us to store the data. However since these services require authentication over SSL, I had to install a security certificate on my Tomcat instance.

So here is how I went about it. First of all, the SSL key generator is part of the core JDK as of Java 1.4. The keytool is available at %JAVA_HOME%binkeytool.exe. Run it as specified at the Apache Tomcat tutorial site:

keytool -genkey -alias tomcat -keyalg RSA

The tool asks a series of questions like name, address etc to write the keystore. Once the key is written, move it to where tomcat can access it in the Catalina directory. Lastly uncomment the HTTPS connector and add the following attributes:

keystoreFile=”tomcat.keystore”
keystorePass=””

Ta..daaa…https!!

I still havent managed to run NoteTag (I am getting connection errors) but thats a battle for tomorrow. Right now I need to go to sleep.

..and a cupful of serverside configuration goodness…

Debugging isnt fun….
But it does have its moments, when you feel you have learnt something new.Like today….

First let me step back a bit and explain ip-domain mapping using host files on Windows. The Hosts file contains the mappings of IP addresses to host names. This file is loaded into memory (cache) at startup, then Windows checks the Hosts file before it queries any DNS servers, which enables it to override addresses in the DNS.[1] The host file is located at ‘C:WINDOWSsystem32driversetchosts’.

Typically, during development, I use host files to map urls for applications under development to the sub-domain of my main site. This allows me to access cookies etc while still running the web-app on my laptop.

While setting up an web-app today I mapped a domain to an ip using my host file, but could not bring the page up no matter how I hard tried. At my wit’s end I called upon our sys-admin and resident Solaris proponent to help me fix this problem. A couple of hours later I was on my way and had a much deeper understanding of server configuration stuff. Before I forget what I learned I figured I may as well save it for posterity by publishing it here.

The problem arose because I was trying to map my domain to an ip of a virtual server. While this is not a big deal (click here to see how Apache does it), there was something weird happening on my machine.
Typically servers, like regular computers, have physical interfaces that connect them to the network. However you can have multiple virtual interfaces each with individually assigned IP addresses on a single physical interface. Within the webserver software, listening sockets were defined and mapped to the IP addresses on our virtual interfaces.
Each of the virtual interfaces are associated with a listening socket and every virtual server instance is bound to that listening socket. Virtual servers themselves can be name based or ip based. IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve whereas name based ones use DNS mappings of IPs to decide which host to serve

The behavior I was seeing turned out to be because while the server’s virtual server instances were bound to individual IP addresses, there were also names that identified what was allowed in the host request field sent by a browser. Since I defined a name in my local hosts file that didn’t match a name defined on the server to be associated with the virtual server instance that I tried to reach, the web server sent my browser’s request to its default, or primary instance.

…I am glad its a Friday !

Contextual aggregated pages on Google

This is interesting. After seeing a trailer for the movie “Lady in the Water” I was intrigued enough to do a google search for it. The first result I was taken to was an aggregated page of all online reviews for the movie, its avarage rating and google search pages to top words used in the movie. There was also a textfield on the original result page to search for tickets for the movie by entering my zip code. [link]

I had seen such pages for music artists [link]already on google but this was the first time I saw anything for movies.

Disaster Recovery

If you are a pretty extensively used service, few things can be as bad as having your site go down. Of late a lot of the services I use seem to keep having outages and since most of them proudly display the “beta” badge, the worst you can do is frown a bit and carry on. Its nice , however, when on rare occasions people do add some personality to the otherwise annoying “Service Down” or 404 page. When I went to flickr a few moments back, I saw this page taking another jab at Ted Stevans’ remarks on net neutrality (made infamous by John Stewart. ).

Flickr Down

I love sites with personality.