Search code examples
javaglassfishglassfish-3

For Glassfish 3, why does DirectConnectionFactory give me a NullPointerException out of the blue when deploying my application?


After working for a good number of weeks, I cannot deploy my application with Glassfish 3 to my local machine. I get:

EJB Container initialization error

and it appears there is a null pointer:

com.sun.messaging.jms.ra.DirectConnectionFactory._createConnectionId(DirectConnectionFactory.java:424)

I occasionally change my application to point to a glassfish instance on another server and have to update the settings for the correct server, but I am sure that the current configuration is proper for my local machine.

What might be causing this sudden behaviour?


Solution

  • A very likely solution, though not one which is immediately obvious, is that a locking has taken place. This often happens on a machine where the IP address is prone to changing. It is one of the first checks that should be performed for an error involving DirectConnectionFactory and it is a behaviour which has carried over since Glassfish 2 (so this fix may work for that as well).

    What you do to fix is:

    1. Go to the folder where your application is deployed (for me it is glassfish3\glassfish\domains{MY_APPLICATION})
    2. Look for imq/instances/imqbroker/lock
    3. Delete that file
    4. Restart glassfish
    5. Try to deploy your application again.