Glassfish 3.1 Exception While Loading

I recently switched over to using GlassFish 3.1 and then 3.1.1 from 3.0 and I so wish I hadn’t. The 3.1 release doesn’t seem to have bought any new toys but it’s brought a whole host of bugs and weird behaviour. The latest piece of oddness described here has just wasted a couple of hours of my life so in the hope that you won’t also have to waste your life here’s the problem.

When you go to deploy your application it fails and you get the following log messages:

SEVERE: Exception while loading the app
SEVERE: Exception while shutting down application container
SEVERE: Exception while shutting down application container : 
        java.lang.NullPointerException

That’s it, you can dig as much as you want you won’t find anything else in any log file that gives a hint as to what has gone wrong. Now then, if you are like me you probably have a couple of stack traces in your logs that you are sure are the problem but you waste time chasing them in the vain hope that GlassFish has told you where the problem is (in my case I have one about Pinyin and one about logback-test.xml not being found).

So I got thinking about what I’d changed in my code and started going back reverting the changes. Turned out the problem was with a bean that I had marked @RequestScoped which I’d changed to @SessionScoped only I’d forgotten to then implement Serializable. Weld doesn’t like this situation and has a panic attack when it sees it, unfortunately for us GlassFish doesn’t report Welds little breakdown other than to mention in passing that there was an exception somewhere.

Update

I’ve just discovered, to my cost, another trigger of this useless error message. The bean I was working on was consuming a User objected produced by another bean. Somehow I had managed to accidentally set the field to public rather than private as I would normally do. Weld doesn’t like this and so refused to start the application.

The real problem I had here was declaring this field was the last thing I did before taking a two week break for Christmas. When I got back my party addled brain couldn’t remember what the last thing I’d been doing was – cue a lot hunting around in the code.

Posted in Java EE and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *