[jboss-user] [Beginners Corner] - Re: javax.naming.NameNotFoundException: jdbc not bound
PeterJ
do-not-reply at jboss.com
Thu May 21 10:48:28 EDT 2009
I'm sorry, I didn't look carefully enough at the config files presented in the wiki entry that I referred you to, and did not realize that the information was not relevant for a web app. Here is an example (usually the basic datasource name is the same in all the files, but I used different names so that you can see which names need to be the same):
*-ds.xml excerpt:
<jndi-name>jdbc/SomeDS</jndi-name>
web.xml excerpt:
<resource-ref>
| <res-ref-name>jdbc/TheDS</res-ref-name>
| <res-type>javax.sql.DataSource</res-type>
| <res-auth>Container</res-auth>
| <res-sharing-scope>Shareable</res-sharing-scope>
| </resource-ref>
jboss-web.xml:
<jboss-web>
| <resource-ref>
| <res-ref-name>jdbc/TheDS</res-ref-name>
| <jndi-name>java:jdbc/SomeDS</jndi-name>
| </resource-ref>
| </jboss-web>
|
datasource lookup in servlet:
InitialContext ctx = new InitialContext();
| DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TheDS");
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4232520#4232520
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4232520
More information about the jboss-user
mailing list