| Author |
Message |
|
|
Post subject: Integrated Sandbox Tomcat 6 jndi name lookup
Posted: Jun 18, 2012 - 06:40 PM
|
|
Registered Member


Joined: Nov 14, 2005
Posts: 2
|
|
Is the integrated tomcat6 making use of contebnts of web.xml and context.xml
myeclipse Version: 9.1
Build id: 9.1-20110701
I am using Myeclipse Integrated Sandbox Tomcat 6
and I would like to setup a jndi name that can be retrieved as below.
ic = new InitialContext();
//ds = (DataSource) ic.lookup("java:/MySqlDSBL");
ds = (DataSource) ic.lookup("MySqlDSBL");
Under WebRoot/WEB-INF
I have context.xml
<Resource name="MySqlDSBL" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="barry" password="XX" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/mydatabase"/>
I also have web.xml
<resource-ref>
<description>My DB</description>
<res-ref-name>MySqlDSBL</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
I keep getting
javax.naming.NameNotFoundException: Name MySqlDSBL is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
thanks
Barry |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jun 19, 2012 - 08:26 AM
|
|

Joined: Nov 11, 2010
Posts: 2152
|
|
|
_________________ Swapna
MyEclipse Support
|
| |
|
|
|
 |
|
|
Post subject: Integrated Sandbox Tomcat 6 jndi name lookup
Posted: Jun 19, 2012 - 03:12 PM
|
|
Registered Member


Joined: Nov 14, 2005
Posts: 2
|
|
Thanks for your reply. Yes those url's seem to backup my findings.
Its seems that WebRoot/WEB-INF/web.xml is read but WebRoot/WEB-INF/context,xml is not. If I copy/update the context.xml at C:\myprojects\xxx\J2EEproject\.metadata\.me_tcat\conf
then it springs into life.
I used these crude lines to show the jndi name was there
InitialContext ic = new InitialContext();
NamingEnumeration<NameClassPair> pig = ic.list("java:comp/env");
while(pig.hasMore()) {
NameClassPair t = pig.next();
log.info ("bl: " + t);
}
Context envContext = (Context)ic.lookup("java:/comp/env");
ds = (DataSource)envContext.lookup("MySqlDSBL");
but as it didn't read context.xml I got messages about url being ""
Anyway all working now. Shame I need to hand copy the file over but still. |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jun 20, 2012 - 05:39 AM
|
|

Joined: Nov 11, 2010
Posts: 2152
|
|
Barry,
Glad that it is working.
Do let us know if you see any issues. |
_________________ Swapna
MyEclipse Support
|
| |
|
|
|
 |
|
|
| |