MyEclipse Forums
This thread has been locked & this forum has been archived.
Please post new topics to Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
View previous topic Printable version Log in to check your private messages View next topic
Author Message
barryal
Post subject: Integrated Sandbox Tomcat 6 jndi name lookup  PostPosted: Jun 18, 2012 - 06:40 PM
Registered Member
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
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-swapna
Post subject:   PostPosted: Jun 19, 2012 - 08:26 AM



Joined: Nov 11, 2010
Posts: 2489

Barry,

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-Context

2. Can you please confirm that the same works in external Tomcat 6 and the issue is only with Integrated Sandbox Tomcat?

_________________
Swapna
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
barryal
Post subject: Integrated Sandbox Tomcat 6 jndi name lookup  PostPosted: Jun 19, 2012 - 03:12 PM
Registered Member
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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-swapna
Post subject:   PostPosted: Jun 20, 2012 - 05:39 AM



Joined: Nov 11, 2010
Posts: 2489

Barry,

Glad that it is working.
Do let us know if you see any issues.

_________________
Swapna
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits