Tuesday, 13 September 2011

PrimeFaces DataTable on Glassfish 3.1

Further to my earlier post about Glassfish 3.1 and re-deploy errors, another (minor) problem has also been found with the JavaEE course, this time with JSF pages.

After using the <p:dataTable> from the excellent PrimeFaces library, you will probably find that the boring plain Data Table is still being displayed.

This can fixed by adding a <h:head> and </h:head> before the <h:body> table. You can leave the head tag empty for now, but you would add in all of the usual HTML elements that are needed on any web page's head tag, such as <title> and any meta tags.

Monday, 12 September 2011

Glassfish 3.1 Problems - "operation on a closed EntityManagerFactory"

The JavaEE course ships with a copy of Glassfish 3.0, so you can get started with your training right away. However, as we say on the course, if you'd rather use a more recent version of Glassfish, you should be ok.

Glassfish 3.1 was recently released, and whilst it should be fine, we've had a couple of reports of problems with re-deploying on this version.

When re-deploying you application, you may see the following symptoms:

  • No "JPA" engine is listed on the engines list. This can be ignored, it seems to be a bug on the admin console and JPA will work as usual.
  • However, after a redeploy (NOT an initial deploy), you may get an error, with the following reported in the log:

    java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManagerFactory.
As far as I can tell, this is a Glassfish admin console bug also. The deployment process should be responsible for opening and closing the EntityManagerFactory, and it looks like it isn't been properly re-opened on re-deployment.

If this happens to you, I can suggest one of the following:

a) Uninstall Glassfish 3.1 and use the version supplied with the course instead. You won't lose any functionality that is important to the course (all I can think of that is missing would be clustering, which isn't needed for the course).


b) Instead of re-deploying, perform a clean deploy by undeploying and then deploying again (remembering to re-enter the Application Name). This is, however, a little tedious to do each time.

We will raise a bug report with Glassfish, in the meantime do let us know if you discover some steps that prevent the problem entirely.