Kousik Rajendran [
http://community.jboss.org/people/kousikraj] created the discussion
"Re: JNDI Lookup fails in JBoss AS 7 [java.naming.CommunicationException]"
To view the discussion, visit:
http://community.jboss.org/message/638361#638361
--------------------------------------------------------------
Hi Abiya,
All you need to do is a very simple arroach. As
http://community.jboss.org/people/wdfink
Wolf-Dieter Fink told
The datasource should only be available inside the server and your
code looks like a standalone client.
You should try running only within JBoss AS 7 Environment. Which means, *you cannot try
connecting from a standalone Java code.* You should try putting the code inside your web
application and test.
What you can do is, *put this block inside a test servlet and deploy and test i*t. This
should work. Note: there is *no need for you to set any property*.
DataSource ds = null;
Context ctx = null;
try {
String strDSName = "java:jboss/datasources/Test";
ctx = new InitialContext();
ds = (javax.sql.DataSource) ctx.lookup(strDSName);
} catch (Exception e) {
}
Hope this works for you.
You can check in deatail on how it works in here
http://kousikraj.wordpress.com/2011/11/25/datasource-configuration-setup-...
http://kousikraj.wordpress.com/2011/11/25/datasource-configuration-setup-...
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/638361#638361]
Start a new discussion in JNDI and Naming at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]