JBoss Community

Re: JNDI Lookup fails in JBoss AS 7 [java.naming.CommunicationException]

created by jaikiran pai in JNDI and Naming - View the full discussion

Instead of doing a lookup:

 

DataSource ds = (javax.sql.DataSource) ctx.lookup("java:jboss/datasources/Test");

 

use injection:

 

@Resource (mappedName="java:jboss/datasources/Test")
private DataSource ds;

 

That'll setup the appropriate dependencies between the servlet and the datasource.

Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community