facebook

Integrated Sandbox Tomcat 6 jndi name lookup

  1. MyEclipse Archived
  2.  > 
  3. Application Servers and Deployment
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #327240 Reply

    barryal
    Participant

    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

    #327265 Reply

    support-swapna
    Moderator

    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?

    #327278 Reply

    barryal
    Participant

    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.

    #327320 Reply

    support-swapna
    Moderator

    Barry,

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

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Integrated Sandbox Tomcat 6 jndi name lookup

You must be logged in to post in the forum log in