[jboss-user] [JNDI and Naming] - Re: JNDI Lookup fails in JBoss AS 7 [java.naming.CommunicationException]

jaikiran pai do-not-reply at jboss.com
Fri Dec 9 06:27:48 EST 2011


jaikiran pai [http://community.jboss.org/people/jaikiran] created the discussion

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

To view the discussion, visit: http://community.jboss.org/message/640748#640748

--------------------------------------------------------------
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
[http://community.jboss.org/message/640748#640748]

Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111209/9230fccb/attachment.html 


More information about the jboss-user mailing list