May
5
Installing mod_jk for Apache 2.2 on Mac OS X 10.5 Leopard
Filed Under Computers & Tech, System Administration on May 5, 2009 | 17 Comments
Note: these instructions also work on OS X 10.6 Snow Leopard, and OS X 10.7 Lion
A few years ago I did a similar tutorial for installing mod_jk
on OS X 10.4 Tiger, but yesterday I discovered that those instructions do not work for Leopard. It took my quite a bit of googling and trial an error, but I’ve found a solution that works, which I’m going to share here. This solution is, in my opinion, a best practices solution, and does not involve any changes to your core apache configuration file (httpd.conf
). These instructions are for the default install of Apache 2.2 that comes pre-installed on OS X 10.5 Leopard. I can verify that these instructions work for Tomcat 5.0.30, but I would be 99% sure they should also work un-changed for Tomcat 5.5.X and Tomcat 6.0.X.
Dec
9
Accessing Auto Increment Values from PostgreSQL with Java
Filed Under Computers & Tech, Software Development on December 9, 2007 | 7 Comments
It’s not uncommon that as part of a complex transaction you need to insert a row into a table with an auto-incrementing primary key and then use the key from the row you just generated as a foreign key in another insert within the same transaction. Java provides a mechanism to return the auto-generated keys from an insert query without the need to execute a second query by means of the function java.sql.Statement.getGeneratedKeys()
. Unfortunately the PostgreSQL JDBC connector does not appear to support this feature (at least the version I am using does not). Given the fact that we do not have this functionality available to us when using a PostgreSQL database we need to use a separate query to retreive the value of the key we just generated. It goes without saying that we need to do this two-step process as part of a transaction but it may not go without saying that the correct way to extract the value for the key is by querying the sequence that the key is being generated from and not by querying the table directly. It is true that most of the time the highest value of the incrementing variable will be the value just inserted but that is not a guarantee.
Sep
23
An Excellent Article on Java Web Development with Apache Struts 1
Filed Under Computers & Tech, Software Development on September 23, 2007 | Leave a Comment
I was searching for a tutorial on setting up custom global exception handlers in Struts 1 when I came across this fantastic article. If you develop with Struts 1 or are thinking of starting development with Struts 1 you really should read this – Jakarta Struts: Seven Lessons from the Trenches
[tags]Java, Apache, Struts[/tags]
May
4
A Non-Scientific Comparison of Java and Perl
Filed Under Computers & Tech, Software Development on May 4, 2007 | 3 Comments
For my post yesterday on the HD-DVD key I needed to convert the 128bit HEX key into a decimal number and then divide it by two. I figured this would be easy. I’d wander over to Google, search for “convert hex to decimal” and hey-presto, I’d get a web-based converter somewhere to bang the hex key into and get out a decimal number. This soon proved not to work in practice for large numbers. All the converters I tried gave me back floating point numbers with very large exponents. The means loads of precision was lost and hence I couldn’t get the exact number the MPAA claimed to own. So I did what I always do when I can’t find a program to do what I want, I hacked something together in Perl! Now, when I say hacked I do mean hacked. It only took me a few minutes to do and what do ya know, Perl lost precision too, giving me an answer of 1.32562788879895e+37. So, I needed to re-implement this algorithm in a language that could give me basically unlimited integer arithmetic. I chose Java because of the java.math.BigInteger
class and because Java is the language I know best. I implemented the same basic algorithm in both languages. It’s interesting to see just how much bigger the Java code is!
[tags]Java, Perl[/tags]
Dec
30
Simple Java Configuration Files and no XML in Sight
Filed Under Computers & Tech on December 30, 2006 | 55 Comments
The last time I discussed Java configuration files it was from the point of locating them on the disk the right way. This time I want to comment on the content of configuration files. There seems to be an obsession with XML in the modern world. Some people seem to think that shoe-horning XML into their applications will somehow magically make them great. I don’t want to completely put down XML because it most certainly has its uses. In fact I use it quite a bit to store complex and potentially incomplete data sets. However, using XML to store simple configuration information is over-kill and makes the configuration file needlessly complex to edit and needlessly complicates your application. Unless you’re writing something huge or some thing complex the chances are you’re configuration file won’t need to be complicated. The chances are all you really need are some name-value pairs to specify a few parameters. If this is the case Java comes with a wonderfully simple solution right out of the box, .properties
files.
[tags]Java, XML, Configuration Files[/tags]
Nov
21
Java Class Loaders & Configuration Files -Why Wasn’t I Taught This in College?
Filed Under Computers & Tech, Software Development on November 21, 2006 | 11 Comments
I’ve often complained that students don’t get taught the important stuff they’ll need for programming in the real world when they study for computer science or even software engineering degrees. I was pretty sure I’d brushed up on my Java enough that I had all I needed to write Java code in the real world but I was proven very wrong over the weekend when I spent literally an entire day on what turned out to be one line of code. The problem was that I had a gaping hole in my understanding of how the JVM works and how programs can interact with it, I was totally ignorant of the power of Class Loaders.
Nov
17
Java Goes Open Source – So What?
Filed Under Computers & Tech, Software Development on November 17, 2006 | 3 Comments
Java going Open Source is old news at this stage but it’s taken me a while to digest. Ideologically I think it is a great move, I’ve always been a little annoyed that Java was not GPL or similar. So it’s good for me as an Open Source fan, but is it also good for me as a Java Programmer? That’s what I’ve been trying to figure out for the last few days and in the end, I think it is.
[tags]Java, Sun, Open Source, GPL[/tags]
Nov
14
Installing mod_jk for Apache 1.3 on Mac OS X 10.4 Tiger
Filed Under Computers & Tech, System Administration on November 14, 2006 | 8 Comments
I’ve done a few previous articles on Apache Tomcat (one for installing it on Linux and one for installing it on OS X), but I haven’t yet mentioned installing the JK Connector (mod_jk
) in any environment. For those who are wondering what on earth I’m on about, mod_jk
allows the Apache web server to serve your Tomcat web apps so they appear on port 80. There are a number of reasons why you might want to do this. Firstly, it provides a simple and secure way to get Tomcat to respond to requests on port 80 without having to have it run as root. Apache is more efficient at serving static pages so it can help increase the efficiency of your web app, and finally it allows you leverage all the power of Apache’s many features for your Java web app.
[tags]Tomcat, Apache, OS X, Mac, mod_jk, Tomcat Connectors[/tags]
Oct
3
Creating an OS X Application from a Java JAR
Filed Under Computers & Tech, Software Development on October 3, 2006 | 8 Comments
On OS X you can run a JARed Java App by simply double clicking the .jar file. This works but it has a few downsides. For a start you can’t keep the app in your dock so you can launch it easily and you also can’t easily launch it with things like HimmelBar. Secondly it will always have the Java JAR icon and if you’re running a few Java JARs this can get very confusing. What you really want is the same Java App but wrapped inside an OS X App. Examples of this would be the OS X version of jEdit. If you have the Developer Tools (XCode) installed on OS X this is trivial to do. If you don’t have the developer tools installed you’ll find and installer for them on your OS X DVD.
[tags]OS X, Java, Application[/tags] Read more
Aug
6
Simple Indexed Properties in Struts Forms – The Missing Documentation
Filed Under Software Development, Computers & Tech on August 6, 2006 | 25 Comments
Struts has support for indexed properties in its form beans. In fact, it has support for both simple and complex indexed properties. Ironically I have been able to find lots of documentation online to explain the more complex situation but none for the simpler one. I have been able to find documentation on using arrays of beans is form beans but not of arrays of simple literals like strings and integers. And I’ve done a lot of googling on the matter. Having the ability to have an array of strings in your form bean is a very handy feature. This is a very handy thing to be able to do and you’d be right to assume that it should be simple, and it is simple, it’s just not documented anywhere I could find (and I spend a lot of time looking). So, to help others who might be stuck with the same problem here is a worked example that should make it all clear.