Saturday, May 17, 2008

Red5 Easier Setup

Like most Java "innovations", Eclipse is a barrier to getting any real work done. After worked for 18 hours or so on my modified Red5, Eclipse decided to throw an OutOfMemoryError on a system with two gigabytes of memory. After the IDE crashed it refused to startup again. I deleted ~/.eclipse and this did not fix the problem. I deleted /usr/local/eclipse and untarred a fresh copy of Eclipse for Java EE developers. This did not fix the problem (the IDE would freeze with 100% cpu usage on the splash screen.) I solved this problem with a program that's not written in Java:

$ rm -rf /usr/local/eclipse

It turns out you can build Red5 much easier without the brilliant and innovative Ecplise IDE. First install Ant. Then install Poison Ivy. Download the Red5 0.7.0 tarball here. Untar the tarball in your favorite development directory (WARNING: the Red5 developers did not add a top level directory in the tarball, therefore you need to create your directory first.)

$ cd dev/javasucks
~/dev/javasucks$ mkdir red5; cd red5;
~/dev/javasucks/red5$ tar xvfz ~/red5-0.7.0.tar.gz

At this point you would normally be able to build red5 without a hitch by issuing the fantastic command:

~/dev/javasucks/red5$ ant

However, the Red5 developers didn't add an ivysettings.xml file to the tarball, even though it's in SVN. So you need to go here and download it. Move the file to the red5 top level directory and you should be able to build red5.

~/dev/javasucks/red5$ mv ~/ivysettings.xml .
~/dev/javasucks/red5$ ant

You can run the resulting standalone server by doing:

~/dev/javasucks/red5$ cd dist
~/dev/javasucks/red5/dist# ./

Friday, May 16, 2008

Red5 With JDBC Database Connections

I was using Carl Sziebert's guide for getting JDBC connection pooling up and running for Red5. Again I'm struck by the vast idiocy of Java programmers. They are sometimes hilariously stupid. The process of getting red5 JDBC hibernation working is a perfect example. Just take a look at Carl's guide (not disparaging Carl personally, he may be an idiot or he may just be misguided.) At the very least he's publishing some method of making this work. Well anyway, contrast his guide with my guide for getting Apache connection pooling working in Perl. Ok, here's the guide!

use Apache::DBI;

Whew, that was tough. I'm glad these Spring people have created this amazing technology that makes connection pooling possible! What an incredibly elegant solution they have created! Five proprietary XML files to edit. I'm astounded at this cutting edge technological innovation which pushes back the oounds of possibility for mankind! All brought to you by the ingenius language Java, which is creating a wonderful new paradigm of simple programming which anyone can understand and maintain. I'm glad those people are out exhaling carbon dioxide, at least they're doing something useful.

Thursday, May 15, 2008

Eclipse, Spring, Red5 on Ubuntu

This is a log of my attempts to set up a Flash streaming server on Ubuntu 7.10 Server.

First I want to mention that I hate Java developers on a very personal level. Their mediocre mental facilities and sheep like tendencies is not an excuse. Java is the cancerous tumor on the ass of the programming world. The Java ideology is blindly idiotic even to the most simple minded among us (or so you would think.) It is rooted in the notion that you can reduce the number of mistakes (bugs) in a piece of software by making the language extremely verbose. The saga of the installation process for these tools is a testament in itself of the fallacy of this position. Notwithstanding the blindly obvious fact that we all know, after all, that verbose language leads to less mistakes. Right? Do you make more mistakes when you are writing a paragraph for a research paper, or a page of dense legal language? Besides this, which one is easier for an author to write? Which one is easier for someone whose second language is English? Enough said.

Unfortunatly, the simple minded fell for Sun's propaganda back in the 90s. Therefore we're stuck with this bastard child. Ironically, Red5 will eventually make Java irrelavent (by opening the market to alternative FMS implementations.) It is, after all, essentially building a technology which was designed to fulfill Java's original intended use. The day that Java is relegated to a few zealous geriatrics (like Lisp is today) is going to be a happy day.

First, get Red5. Get the .deb from Red5 here. Next run the deceptively simple installation command:

sudo dpkg -i red5_0.7.0_all.deb

On a stock Ubuntu system it will fail horribly. It needs sun-java5-jre.

sudo apt-get install sun-java5-jre

Amazingly, this doesn't work without half an hour of Googling why. It fails with an unsatisfied dependency "sun-java5-bin". Which if you try to install you get an unsatisfied dependency of "sun-java5-jre". Which if you try to install you get a helpful unsatisfied dependency of "sun-java5-bin".

The solution is to run:

sudo apt-get install

And accept their nefarious license agreement. But a quick check of the process list will show that there is no Red candy. There are no error messages to speak of, this is a wonderful example of Java in action. If you snoop around you find /etc/init.d/red5. Why not try and start it?

sudo /etc/init.d/red5 start

Well. It says it started. That's odd, there's nothing in the process list. It looks like it's calling a script /usr/lib/red5/ Let's try that.

sudo /usr/lib/red5/

Aha! A typical 50 line Java exception. I forget exactly what the exception is, don't really care. The solution is to run:

sudo update-alternatives --config java

Then select the sun-java5-jre option. This exception is ocurring because our wonderful Ubuntu overlords don't like the fact that Java is closed source. They'd rather that we use GCJ for politcal reasons. It is because of this they decided to waste my time. Thankfully, Sun finally pulled their head out of their ass and released their pile of crap as Open Source(tm), which should save us headaches when we have to use this crap in the future. Another run of /etc/init.d/red5 start will give us a working Red5. You should be able to navigate to it at:


Next we need to install Eclipse, at least if you want to do any development. For those of you who are unaware, java is such a poorly designed language that it requires a mammoth IDE in order to get any work done in it.

# Don't run this, read on for a fix.
sudo apt-get install eclipse

This doesn't work. Yes, it will install Eclipse. Unfortunately, the Ecplise it installs will not work. There is a user friendly Java exception in the upper right corner. The solution is to open "/etc/eclipse/java_home" and move (or add) the line "/usr/lib/jvm/java-1.5.0-sun" at the top of the file. This is because Eclipse is too dumb to find the right JVM on its own. Additionally, the Eclipse version which is in the Ubuntu repositories is too old, it will fail several hours after tweaking with it trying to make it work with Red5. So instead download the Eclipse IDE for Java EE Developers (version 3.3.2 as of this writing.) Untar the file and move it to /usr/local/eclipse.

tar xvfz eclipse-jee-europa-winter-linux-gtk.tar.gz
sudo mv eclipse /usr/local

Now start the Eclipse IDE like so:

This will fail trying to write a few files to various places which require root access. The program appears to be ignorant about file permissions. You can start it once with:
sudo /usr/local/eclipse/eclipse

Then close it and start it again and the problem seems to go away. You may need to add or edit /etc/eclipse/java_home or not. Now you need to install Springboard or whatever the fuck it's called. The instructions are here. An important thing to notice here is 'Don't try to install the "Spring IDE Dependencies (only for Eclipse 3.2.x)" from the "Dependency"'. Typical of Java developers, their program is not smart enough to figure out which version it is and handle this for you. You also need to install Subclipse for SVN management. And Poison Ivy if you want to build the Red5 system. I used Cal's excellent installation guide here. Otherwise, you appear to be able to build Red5 applcations without them.

If you need to connect to MySQL you can run:

sudo apt-get install libmysql-java

This installs JDBC and the MySQL Connector correctly.