Site Navigation

Sep 13, 2010

javax.naming.NamingException: Lookup failed for 'jdbc/dbname' in SerialContext

Duke WavingWhile trying to deploy a Java EE6 Web application with NetBeans and Glassfish V3, the application deployment fails with the following error.

SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'jdbc/dbname' in SerialContext [Root exception is javax.naming.NameNotFoundException: dbname not found]

What does this mean? Basically, you have not defined the JDBC resource in the Web Application. In my case, neither the Database Connection Pool nor the JDBC resource had been defined. Once the persistence resources are defined, the application should deploy without any errors.

When first analyzing the problem, I thought, incorrectly, that since the persistence resources were defined in an included library, no definition was required in the Web application. This is not the case.

Update
A reader made a fair point that no pointers on how to create the JDBC resource or Connection Pool are included in this post. Here are the steps assuming you already have a Java EE project created. Right click your project and select the following menu options.
  • Connection Pool New -> Other -> Glassfish -> JDBC Connection Pool
  • JDBC Resource New -> Other -> Glassfish -> JDBC Resource
The wizard for each will walk you through the setup. Hope that helps.
Post a Comment

Favorite Links Feed