javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Published: December 8, 2010 , Updated: December 8, 2010 , Author: mkyong
Problem
JSF 2.0 web application, a managed bean uses @Resource to inject the “jdbc/mkyongdb” datasource into a ds property.
@ManagedBean(name="customer") @SessionScoped public class CustomerBean implements Serializable{ //resource injection @Resource(name="jdbc/mkyongdb") private DataSource ds;
When deployed to Tomcat 6, it hits following error messages for the MySQL datasource configuration.
com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean customer at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:207) Caused by: com.sun.faces.spi.InjectionProviderException: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at com.sun.faces.vendor.Tomcat6InjectionProvider.inject(Tomcat6InjectionProvider.java:84) at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:201) ... 53 more Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) ... 54 more
Solution
The “jdbc/mkyongdb” datasource is not configure properly in Tomcat, see this guide for detail – How to configure MySQL DataSource in Tomcat 6
Note : You can find more similar articles at - JSF 2 Tutorials







