My first sample web application in GlassFish 3 server involving JPA 2.0 and GlassFish was spitting out the error "
Unable to retrieve EntityManagerFactory for unitName XXX". Other settings were right.
Solution: Edit domain.xml to enable JPA as below. By default JPA is enabled for EJB modules.
<module name="yourwebmodulename">
<engine sniffer="jpa"></engine>