Main

June 11, 2007

Where is the isOpen()/isClosed() on javax.jms.Connection

I mean really, why doesn't the JMS spec dictate that there is a programatical way to determine if a JMS Connection is open or connected?

I have built a JMSBroker to handle all the internal JMS stuff to create connections and get access to Queue's and Topics, but the biggest issue I have to deal with is reconnection.

It seem that we often have connection issues to the JMS Server, and so want to have the underlying JMS client side layer automatically handle this and retry the message. To do this I have to use the following logic.

Build the Packet,
Try to send it,
If that works YAY packet out.
Otherwise...
work out what failed,
- which could be either the connection or the session.
- Theres no way to know except which method call failed, so the try catch loops have to be tight with error handling in multiple places.
- Re-connect each of the broken bits, and go back to the start.

Would it be much nicer to do:
- getConnection() - checks if cached connection is open, if so returns, else creates a new one and returns.
- getSesison() - checks if cached session is open, if so returns it else calls getConnection().createXXXSession()
- Message uses session to send out..

Now isn't that cleaner...

I think so.

April 28, 2007

Trying Eclipse - Part 1

I have long been an Eclipse Junkie, but recently have found that I am hearing more and more about NetBeans, even using it in parts over the last 12 months to do some quick UI work. So I have now undertaken a serious effort to get my projects working and editable inside NetBeans.

I'm running the 6.0 dev version M8, and so some of my issues may just be due to the Dev nature of the build.

So in this post I'll give my inital feelings, then look at later ones as to pros and cons of NetBeans vs Eclipse.

Straight off the bat its nice and small. 40 odd MB for the NB IDE version, in comparison to 150+ for the Eclipse / WST bundle. I guess NB is a bit bigger as I used the Update Center to get all the editing tools for the web stuff, but still feels way under the 150+ that Eclipse is.

Maven integration is COOL. With a capital Cool... I just check out each of my modules then do Project Open and boom... Project is open, all dependecies are downloaded, and different code sections are layed out nicely.

Things I miss, or can't find yet:
- A problems view for each project? Must be there somewhere but can't see it.
- Collapsing packages to those that only contain classes or multiple sub packages
- Sync the Package Tree and selected file.

But so far so good.. Update later

September 5, 2006

JDK 6.0 on Ubuntu

After hunting around to get JDK6.0 Beta2 on ubuntu working, I found a post on the debian-java mailing list that shows some simple changes to allow java-package to generate a debian package correctly.

http://www.mail-archive.com/debian-java@lists.debian.org/msg10870.html

From the site it is:

Adapting java-package to 6.0 was nothing more than trivial.

(1)
# cd /usr/share/java-package
# cp -ax sun-j2sdk1.5 sun-j2sdk6.0

(2)

sun-j2sdk.sh is the script that handles the Sun JDK (you know better than me) and it needs only a few tweaking:

# diff -u sun-j2sdk.sh.orig sun-j2sdk.sh
--- sun-j2sdk.sh.orig 2005-04-22 19:33:46.000000000 +0200
+++ sun-j2sdk.sh 2006-05-16 22:01:28.948657750 +0200
@@ -35,6 +35,11 @@
j2se_expected_min_size=130
found=true
;;
+ "jdk-6-beta"*) # EXPERIMENTAL
+ j2se_version=6.0.0+beta-${archive_name:17:2}
+ j2se_expected_min_size=100
+ found=true
+ ;;
esac
;;
"ia64-linux")


Now make-jpkg handles Java 6.0 Mustang binary snapshots as it dows with 5.0 releases.

$ fakeroot make-jpkg jdk-6-beta2-bin-b84-linux-i586-11_may_2006.bin
...
$ ls sun*
sun-j2sdk6.0_6.0.0+beta-84_i386.deb

The only changes I had were that I had to change
j2se_version=6.0.0+beta-${archive_name:17:2}
to
j2se_version=6.0.0+beta-${archive_name:10:1}

This was due to me using the jdk-6-beta2-linux-i586.bin binary instead of the one specified in the thread.

June 17, 2006

Why is it a little cross?

Ever wondered what made the developers of windows choose the icons for close, minimise and maximise?

It came to me the other day that the choice for the close button has more than one meaning.  Yes the cross is standard for no, cancel, remove which is basically what you are doing when want to close the window, but another more accurate term came to me. 

When you want to leave somewhere you “Exit” the building, so taking the visuals litterly when you click on the close icon, you are X-ing it, or X-it-ing.

So now when ever you click the little close button you can rememeber that not only are you closing the window, but X-it-ing it too.

May 31, 2006

Linux Tomcat Chkconfig Script

I've been meaning to post this for a while, this is my script that can be used to allow tomcat to start and stop with the server cleanly.
It will startup tomcat as one of the last services (95) and shut it down pretty early too.

Feel free to take it, I primarly posted it here so that I can find it when I install tomcat on a new server.
#! /bin/bash
#
# tomcat          Start/Stop the Tomcat Http/Servlet server.
#
# chkconfig: 2345 95 65
# description: Tomcat is a java based HTTP/Servlet server
# processname: tomcat
# pidfile: /var/run/tomcat.pid

# Source function library.
. /etc/init.d/functions
. /etc/profile

RETVAL=0
TOMCAT_HOME=/usr/local/tomcat
# See how we were called.

start() {
        echo -n $"Starting Tomcat "
        $TOMCAT_HOME/bin/startup.sh
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch  /var/lock/subsys/tomcat
        return $RETVAL
}

stop() {
        echo -n $"Stopping Tomcat "
        $TOMCAT_HOME/bin/shutdown.sh
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/tomcat
        return $RETVAL
}

restart() {
        stop
        start
}


case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  status)
        ps ax | grep $TOMCAT_HOME
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1
esac

exit $?

May 15, 2006

Playing with Netbeans Mobility Pack

Recently I installed Netbeans 5.0 to try out the Matisse GUI editor, and so far its been great.  Now being an eclipse person its hard to cross over to NB full time, so i’m just using it for my GUI creation and doing all the heavy lifting in eclipse.

A new project at work relates to Mobile applications, thus brining be back to Netbeans again. After listening to the Java Posse and hearing about the Netbeans Mobility Pack I thought now is a good time to try it.

I have little to no experiance with MIDP applications, but within 10 mins of getting the Mobility Pack installed, I had a functioning application working and testable in a simulated phone. Ok, so it didn’t do much, but it did at least let me get my feet wet without all the extra work.

I especially like the Flow Design section that allows you to drag and drop links between screens to manage the navigation.

April 6, 2006

Java Gaming

After listening to The Java Posse podcast, I heard about a few Java games written that start to show off the performance of java in a game development.  I'm sure there are heaps more available, but so far I have found and tried:

And have on my list to try

Feel free to post a comment here on more games..  If I find may more or have any review I'll keep you updated.

August 26, 2005

Building and installing mod_jk

I can never remember where mod_jk’s sources are and the way to build it, so here is a quick reference for me to remember.

To use aspx install the httpd-devel package via apt-get

Apache mod_jk
-------------
# cd /usr/local/src
# wget http://apache.mirror.pacific.net.au/jakarta/tomcat-connectors/jk/source/jakarta-tomcat-connectors-current-src.tar.gz
# tar xzvf jakarta-tomcat-connectors-current-src.tar.gz
# cd jakarta-tomcat-connectors-1.2.10-src
# cd jk/native
# ./configure -with-apxs=/usr/sbin/apxs
# make
# make install

July 25, 2005

News: Yahoo! acquires Konfabulator

The Konfabulator widgets are something that I’ve played with a while ago, and really looked at building a couple, but got caught with having to pay for the runtime to run them.  Now Yahoo! is looking at releasing it for free, it may be a more attractive platform.

Macworld: News: Yahoo! acquires Konfabulator

Yahoo! Inc. on Monday will announce the acquisition of Konfabulator, a Macintosh and Windows application that allows users to run mini files known as Widgets on their desktop -- the same model used by Apple for its Dashboard application. Yahoo! company executives said they would also be giving Konfabulator away for free, completely doing away with the US$19.95 currently charged for the product.

Tags:

July 18, 2005

Tom Riddles Diary (via AJAX)

A very cool page I just stumbled upon (via the AJAXIAN blog) is a site that simulates Tom Riddles Diary.

For those who aren't Harry Potter fans, Tom Riddles Diary contained a copy of Tom Riddle and would talk to people via them writing in the diary.  This website works in much the same way, you enter text onto the page and Tom answers the questions.  It works all in realtime using ajax technologies.

Pretty cool.

Check it out at:
http://pandorabots.com/pandora/talk?botid=c96f911b3e35f9e1

I asked it questions about how it works, and what it is. It answers the questions well. Even things like what it the capital city of …. seems to work.  But I did stump it with the Atomic Weight of Gold… I guess not everything can know everything.

Play and feel free to comment here on any interesting questions to ask.

Now playing: steve@gillmor.com - Gillmor Gang Goes East

Tags:

July 14, 2005

Online newspaper reader (AJAX)

We all know that most newspapers have an online presence, but its limited to what they decide to publish and its not like the real thing.

But now due to the wonders of the internet you can read the paper in its original format, scanned and digitised for your viewing pleasure.

http://www.pressdisplay.com/pressdisplay/viewer.aspx

What's more, is that its a funky site using heaps of AJAX technology and showing us that someone else than Google can really use this technology to make some cool stuff.

Now playing: Green Day - Homecoming

July 12, 2005

OpenJMS

We have been using OpenJMS for a fair while around here for some development stuff.  I recently went back to check for an update, as we were running 0.7.6 and I thought that there might a 1.0 or even an minor update.

Upon heading over to the site I found a new release 0.7.7–alpha1. Now I'm a casual user of alpha’s, but for something as critical as our JMS component i would not usually use an alpha, but if u head over to the site and have a look at the downloads page it would seem that this is the only release, and not only that but it portrays to be the stable release.

That said, I DO know it a sourceforge project, and I DO know that I can access the downloads list and grab the most recent stable release, but for others just stumbling along they would read this to be either a new project still in alpha, or not see the alpha and consider it as stable.

After all of that ranting, we are using it, and apart from some headaches of migrating from 0.7.6 it seems to be working fine.  Or at least fine enough for development.

So now this rant is over, it must be time to get back and post some questions/issues to the OpenJMS mailing list.

June 29, 2005

Eclipse 3.1 Released

It seems that the good folks have just released Eclipse 3.1.  I’ve been running Eclipse 3.1 for a while now, up through M3 and M4. But now its released.

I’ll be holding off a little bit, as the main plug in I use (the web tools project) is about to release their 0.7 M5 in the next couple of days, and once thats declared I think I’ll move to both 3.1 and WTP 0.7M5.

June 24, 2005

Garbage Collection and the WeakHashMap

I’ve had some issues with DCAF in recent times. The main issue is the DataChangeManager and its in-ability to release locks on elements that are no-longer used inside the application.

Let me take a step back.  In DCAF there is a DataChangeManager. This is a singleton that you can register with to receive notifications of changes to a specific class or instance of a BaseBO.

Now in some applications an instance of a BaseBO registers itself as a listener to itself..  Why would u do this? I hear you ask.. In a distributed system where there are multiple VM’s modifying similar data, its useful to be notified of  these changes and reload the data accordingly.  In conjunction with  a DataChangedTransport using something like JMS this is a simple solution.

So now you know the situation, what is the issue.  The problem is that the DataChangeManager has a fixed reference to the BO, and if that BO is no longer used by the application the Garbage collector should release it.  But as the DataChangeManager is static, and has a reference to this BO the GC is still considers the element reference, even tho technically it isn’t going to be used by the application again.  So we get a memory leak.

For a webapp I was working on, we had the User entity listening to itself for changes, and the entity was in a HttpSession.  So while the session was active, the User was valid and being used within the application.  Changes on a remote VM were propagated across, the User was notified and the contents reloaded.  All working nicely. 

But then the session is not interacted with for a while (the user closes the browser) and so the session timeout.  The servlet container disposes the session and unlinks the User from it, so its no longer used, and we would assume its valid to be GC’d. But in the background the DataChangeManager still retains a reference and so the User lives on.

Without boring you on the details of how the GC works (you can read that anywhere) I’ll just cover the bits relevant here.  Basically an object can be GC’d when it is not longer referenced by any valid threads or static instance.

In the previous example, User is referenced via the static DataChangeManager instance and so is not GC’able.

Now to the solution.

What needs to happen is to trick the GC into believing that the reference from the DataChangeManager to the User does not exist, so once all other reference are removed, the User is seen to be GC’able.

This sort of reference is called a “Weak Reference”.  From my very quick and limited search through the current Java API’s there is a data structure that stores some data using Weak References, and this is a WeakHashMap.

The keys stored in this map are Weak References, and so not considered by the GC when it is time to work out what object can be GC’d.

So the change, was to update the internals of the DataChangeManager to store the references to the DataChangeListeners in a WeakHashMap instead of a List.

So there, hope that shows off another feature of the Java system that you may not have been too sure about. Please feel free to comment about this approach here, and if you want to try it out for yourself then head over to the development site to pickup a version of DCAF .  These changes will be in the 1.2 release of DCAF to be released in the next week or so.

May 27, 2005

Eclipse and Working Sets

Call me silly, but its taken me months to find out what these Working Sets things are in Eclipse..  I’ve introduced some guys at work to Eclipse and in discussing with them I noted that the only thing that I didn’t like was that I had to have all of my projects open in one view.

Given that I have about 25–30 sets of project code, this was annoying..  My first solution was to use Workspaces to divide up the projects. But this caused all settings and configuration to be stored with a specific set of projects.  Things like User Libraries, editor preferences and even things to plugin configurations needed to be applied to all of my workspaces to keep my development consistent.

It was during this chat to a bloke at work that I thought, hang on.. I know there are these things call Working Sets, and have pretty much dismissed their function, but they are probably what i’m looking for…  And guess what!!  They are.

Now I can import all of my projects to one workspace and divide them up using working sets..  It just shows that sometimes you can’t see the forest for the trees.

So back to eclipse I go, waiting for the 3.1 final to be released and the WTP 1.0..  That said the milestone builds of both are excellent, and I would highly recommend to everyone (especially those doing jsp/html/xml work) to upgrade to the latest milestones of both Eclipse and WTP to get all the new goodies.

May 12, 2005

Hungarian Notation

Joel has updated his site with a post about Hungarian Notation, not only is it an interesting read as usual, but his example talks about Cross Site Scripting.

Being a webdeveloper for a few years now, its interesting to see XSS mentioned in such a simple fashion.  We have had solutions for this since day one, but I don’t think that I have ever actually know the true definition of Cross Site Scripting.

On the Hungarian Notation side of the article, I can see what he means to use prefixing to highlight subtypes of data, but i’m sure that that sort of notation needs to be controlled so as to not fly way off into complex land.

As usual the article is a great read, well written and puts forward smart and sensible points.  Thanks Joel.

May 9, 2005

Product Release Management System

I’m about to release a new beta version of my DCAF and WAF java librarys, but in doing so I want to have a system on my website that allows me to create a release, add notes and a series of files to download.

I’ve been hunting around, but its hard to find a term to google for this type of product.  Words like release, software, version are all very popular terms on the internet and so how to find the actual product amongst all of the other pages.

So any suggestions as to a software package that can do this?

I’d love this product to have the following features:

  • Ability to create a new release that contains files and release notes
  • Be able to manage different product streams
  • Be able to track the number of times the files are downloaded
  • Be able to have private products that require a valid login to download

I think thats about it…  I’ll keep hunting for a while and see what I can find, it probably doesn’t matter what technology the application is developed in, just that it works.

May 1, 2005

Answers: Acronym Soup

I’ve been slack in giving the answers to the quiz from the other week (Java Quiz: Acronym Soup) so here they are:

  1. JMS (Java Messaging Service)
  2. JDBC (Java Database Connectivity)
  3. JCP (Java Community Process)
  4. JSP (Java Server Page)
  5. JTA (Java Transaction API)
  6. UDDI (Universal Data Discovery Intergace)
  7. JSWDK (Java Server Web Development Kit)
  8. BMP (Bean Managed Persistance)
  9. JAXP (Java API for XML Parsing)
  10. JAF (Java Activation Framework)

What a preliferation of Java’s….

 

April 22, 2005

Java Quiz: Acronym Soup

For this weeks quiz I decided to dive into the world of Java Acronyms..  We live with them daily, and some of them have even evolved to be a word of their own and not an acronym (SOAP).  So enough of the chatting, lets get quizzing.

Here are 10 Java based acronyms, name the complete extension:

  1. JMS
  2. JDBC
  3. JCP
  4. JSP
  5. JTA
  6. UDDI
  7. JSWDK
  8. BMP
  9. JAXP
  10. JAF

So there they are, not to hard, answers in 2 days… wanna really test yourself, check out a list of 100 Java Acronyms  Acronym Anarchy: Java Evolutions

April 19, 2005

Tomcat serving PHP

Found this interesting article PHP on Tomcat that talks about configuring tomcat to serve PHP files, which got me thinking,  I guess someone has written a servlet or a wrapper for most technologies.

I wonder if this approach makes PHP more or less secure? I havn’t tried this myself or read much of the PHP background to how this works, but it looks like it delegates to the local machines dll, which I guess bypasses all the JVM’s security manager.

April 18, 2005

Cooltools Indoor Cricket

Just a quick note to say that my indoor cricket system is now open to the public, if there are any Indoor Cricket teams out there that would like to use crickscore, then email me, or leave a comment and I can arrange to create access for your team.

My indoor cricket team uses crickscore to manage its fixtures, team status, results and statistics. Check out our site at Cooltools Indoor Cricket.

Update 19/4: Got a query as to why this is included in my Java category. The reason is that the technology behind the development of Crickscore is entirly java..  I posted it to this category to show what can be done with Java technology.

April 17, 2005

Fixed RSS feed... I hope

Sorry, again, to the JavaBlogs world, it seems that I was not actually removed and all my non java related posts were still heading there..  I have unsubscribed that feed from JavaBlogs now so there should only be the Java related items.

I’ll post another non-java test to make sure that they don’t show up any more.

April 16, 2005

New Best Bets Sports Guide

A couple of weeks ago we launched a new JSP/Servlet based application for Best Bets. This new site uses all of the Whitesquare technologies, (DCAF WAF)

Check out the new site Best Bets Sporting Guide.

April 15, 2005

Return to Java Blogs

I'm hoping to get my blog back onto JavaBlogs over the next few days.  I was removed due to the lack of posts in relation to Java. 

I totally agree with the issue I was causing, but it couldnt be fixed using SnipSnap, so with the move to MT I hope that a caregory for java will allow me to keep only java related posts from showing up on JavaBlogs.

This should hopefully be the first item to appear there.