- This topic has 3 replies, 2 voices, and was last updated 12 years, 6 months ago by support-swapna.
-
AuthorPosts
-
barryalParticipantIs the integrated tomcat6 making use of contebnts of web.xml and context.xml
myeclipse Version: 9.1
Build id: 9.1-20110701I 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
support-swapnaModeratorBarry,
Sorry that you are seeing this issue.
1. Can you please take a look at these links and see if the solution helps you ?:
http://www.coderanch.com/t/466539/vc/Unable-configure-tomcat-datasource-within
http://www.coderanch.com/t/442367/Tomcat/Name-jdbc-not-bound-Context2. Can you please confirm that the same works in external Tomcat 6 and the issue is only with Integrated Sandbox Tomcat?
barryalParticipantThanks 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.
support-swapnaModeratorBarry,
Glad that it is working.
Do let us know if you see any issues. -
AuthorPosts