Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
30 replies Latest Post - ‏2010-09-15T03:08:55Z by Jeuz
SystemAdmin
SystemAdmin
1215 Posts
ACCEPTED ANSWER

Pinned topic javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

‏2004-07-07T07:56:15Z |
Hi,
I'm using Websphere Studio Enterprise Developer.

I get the following error:
javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:"

This is my code:

<%@page import="javax.naming., java.sql., javax.sql.*"%>
<% Connection conn;

java.util.Properties parms = new java.util.Properties();
parms.setProperty (Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");

Context ctx = new InitialContext(parms);

DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/OracleSample");

conn = ds.getConnection("dw", "dw");

%>

Any idea, please?

Davinia.
Updated on 2010-09-15T03:08:55Z at 2010-09-15T03:08:55Z by Jeuz
  • SystemAdmin
    SystemAdmin
    1215 Posts
    ACCEPTED ANSWER

    Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

    ‏2004-07-07T18:53:32Z  in response to SystemAdmin
    try posting your code again and i can probably help you
    • SystemAdmin
      SystemAdmin
      1215 Posts
      ACCEPTED ANSWER

      Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

      ‏2004-07-19T08:12:53Z  in response to SystemAdmin
      I face the same problem :
      javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:"

      The source :
      public Connection getConnection()
      throws ClassNotFoundException, SQLException, Exception {
      Connection conn = null;
      try {
      InitialContext ctx = new InitialContext();
      DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/WBSRC");
      conn = ds.getConnection();
      conn.setAutoCommit(false);
      } catch (SQLException e) {
      e.printStackTrace();
      throw e;
      } catch (Exception ne) {
      ne.printStackTrace();
      throw ne;
      }
      return conn;
      }
      I am using Websphere 5.1 on Windows 2000 and Unix.

      I have created a Datasource with the name : jdbc/WBSRC

      I have not specified anything related to jdbc/WBSRC in web.xml
      • SystemAdmin
        SystemAdmin
        1215 Posts
        ACCEPTED ANSWER

        Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

        ‏2005-01-13T15:04:09Z  in response to SystemAdmin
        how did you fix?

        "deepakgm1" <deepakgm@hotmail.com> wrote in message
        news:638351985.1090224773993.JavaMail.wasadmin@swg3ws003...
        > I face the same problem :
        > javax.naming.NameNotFoundException: Name comp/env/jdbc not found in
        context "java:"
        >
        > The source :
        > public Connection getConnection()
        > throws ClassNotFoundException, SQLException, Exception {
        > Connection conn = null;
        > try {
        > InitialContext ctx = new InitialContext();
        > DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/WBSRC");
        > conn = ds.getConnection();
        > conn.setAutoCommit(false);
        > } catch (SQLException e) {
        > e.printStackTrace();
        > throw e;
        > } catch (Exception ne) {
        > ne.printStackTrace();
        > throw ne;
        > }
        > return conn;
        > }
        >
        >
        > I am using Websphere 5.1 on Windows 2000 and Unix.
        >
        > I have created a Datasource with the name : jdbc/WBSRC
        >
        > I have not specified anything related to jdbc/WBSRC in web.xml
        >
        >

      • SystemAdmin
        SystemAdmin
        1215 Posts
        ACCEPTED ANSWER

        Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

        ‏2005-03-22T07:05:18Z  in response to SystemAdmin
        i am also using WSAD 5.1.2 still facing the same problem .did u solve this, if yes pls help me
        • SystemAdmin
          SystemAdmin
          1215 Posts
          ACCEPTED ANSWER

          Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

          ‏2006-02-03T14:54:21Z  in response to SystemAdmin
          > i am also using WSAD 5.1.2 still facing the same
          > problem .did u solve this, if yes pls help me

          I was having the same problem, but I solved it.
          You only 've to use "jdbc/myDatasourceName". Don't write "java:comp/env/jdbc"

          I hope help you.

          Bye
  • SystemAdmin
    SystemAdmin
    1215 Posts
    ACCEPTED ANSWER

    Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

    ‏2004-09-07T14:54:27Z  in response to SystemAdmin
    > Hi,
    > I'm using Websphere Studio Enterprise Developer.
    >
    > I get the following error:
    > javax.naming.NameNotFoundException: Name
    > comp/env/jdbc not found in context "java:"
    >
    > This is my code:
    >
    > <%@page import="javax.naming., java.sql.,
    > javax.sql.*"%>
    > <% Connection conn;
    >
    > java.util.Properties parms = new
    > java.util.Properties();
    > parms.setProperty (Context.INITIAL_CONTEXT_FACTORY,
    > "com.ibm.websphere.naming.WsnInitialContextFactory");
    >
    > Context ctx = new InitialContext(parms);
    >
    > DataSource ds =
    > (DataSource)ctx.lookup("java:comp/env/jdbc/OracleSampl
    > ");
    >
    > conn = ds.getConnection("dw", "dw");
    >
    > %>
    >
    > Any idea, please?
    >
    > Davinia.

    Hi,

    I had a similar problem. Try this. Set up a datasource alias and refer to it as follows.

    Open "Web.xml" in your project and from the "References" tab select the "Resources" tab.

    Add a new resource and name it whatever you like e.g "ds1". Then type in the jndi name exactly as configured in your datasource e.g "jdbc/ds1"

    Then change your code to refer to the alias "ds1":

    DataSource ds =
    (DataSource)ctx.lookup("java:comp/env/jdbc/ds1");

    Hope this helps.
    • SystemAdmin
      SystemAdmin
      1215 Posts
      ACCEPTED ANSWER

      Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

      ‏2004-10-15T17:05:57Z  in response to SystemAdmin
      Check your ibm-web-bnd.xmi It should have binding information for the jndi name like

      resRefBindings xmi:id="ResourceRefBinding_xxxxxxx" jndiName="jdbc/testDataSource"

      You can add it using IDE by editing web.xml
      Refrences --> Resource and selecting the Resource Refrence in this case it was e.g jdbc/testDataSource.
      • SystemAdmin
        SystemAdmin
        1215 Posts
        ACCEPTED ANSWER

        Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

        ‏2004-12-17T18:10:27Z  in response to SystemAdmin
        Hi,
        I have the same problem , but slightly different from the above said ones. I have an application which runs many threads and is loaded from a servlet. I have a Datasource configured and have a resource reference defined for the purpose.

        I am able to get the reference to this Datasource through Resource reference when called directly from the servlet's thread. But if one of the other threads (application threads) tries to access the Datasource I get the exception " javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:" ". I have a utility class which returns the datasource and I get exception when the same is called from a different thread other than the main servlet thread. This is true only for Resource reference lookups (in my case java:comp/env/jdbc/sample). I am able to get the reference , both from servlet thread and the other threads ,if i directly use the jndi binding (in my case it is jdbc/sample). I am confused about how to proceed , I can get away by directly using the acutal JNDI name and not Resource Reference, but I get some messages in log when i do that and I have read somewhere that it happens when you dont access the resource through a resource reference.

        Could this be a bug with Websphere or I am missing some important detail of configuring. I tried this on both the Test Environment and Base version with Deployment Manger. Attaching is the Servlet I used for testing.

        Source

        import java.io.IOException;
        import javax.naming.*;
        import javax.servlet.*;
        import javax.servlet.http.*;
        import javax.sql.DataSource;
        import com.test.TestContext;

        class MyThread extends Thread{
        public void run() {
        try {
        InitialContext context = new InitialContext();
        DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/avs1sun");
        System.out.println("Datasource = " + ds);
        }catch (Exception e ){
        e.printStackTrace();
        }
        }
        }

        public class TestServlet extends HttpServlet implements Servlet {
        public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
        MyThread t = new MyThread();
        System.out.println("Running using Servlet's main Thread");
        t.run();
        System.out.println("Now running using a new Thread");
        t.start();
        }
        }
        Result


        12/17/04 23:32:14:219 IST 3c9bcae3 WsServer A WSVR0001I: Server server1 open for e-business
        12/17/04 23:32:17:547 IST 68d08ae1 WebGroup I SRVE0180I: AVSCoreAppWeb [/AVSCoreAppWeb] http://Servlet.LOG: TestServlet: init
        12/17/04 23:32:17:562 IST 68d08ae1 SystemOut O Running using Servlet's main Thread
        12/17/04 23:32:17:578 IST 68d08ae1 SystemOut O Datasource = com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@4835caed
        12/17/04 23:32:17:578 IST 68d08ae1 SystemOut O Now running using a new Thread
        12/17/04 23:32:17:594 IST 6ae98ae1 SystemErr R javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
        12/17/04 23:32:17:594 IST 6ae98ae1 SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1663)
        12/17/04 23:32:17:594 IST 6ae98ae1 SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1009)
        12/17/04 23:32:17:594 IST 6ae98ae1 SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:932)
        12/17/04 23:32:17:609 IST 6ae98ae1 SystemErr R at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1261)
        12/17/04 23:32:17:609 IST 6ae98ae1 SystemErr R at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:194)
        12/17/04 23:32:17:609 IST 6ae98ae1 SystemErr R at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:135)
        12/17/04 23:32:17:609 IST 6ae98ae1 SystemErr R at javax.naming.InitialContext.lookup(InitialContext.java:360)
        12/17/04 23:32:17:609 IST 6ae98ae1 SystemErr R at MyThread.run(TestServlet.java:17)
        • SystemAdmin
          SystemAdmin
          1215 Posts
          ACCEPTED ANSWER

          Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

          ‏2004-12-21T19:02:15Z  in response to SystemAdmin
          It seems as though user defined threads do not get a copy of the JNDI context. I suggest either using async beans

          http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/ae/rdat_isolevtab.html

          or looking up the datasource in the main thread and saving it off to use in the user defined threads.

          Good luck!
          • SystemAdmin
            SystemAdmin
            1215 Posts
            ACCEPTED ANSWER

            Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

            ‏2004-12-21T19:05:28Z  in response to SystemAdmin
            Sorry, the above link was messed up. Try:

            http://publib.boulder.ibm.com/infocenter/wasinfo/topic/com.ibm.wasee.doc/info/ee/asyncbns/tasks/tasb_epasb.html
            • SystemAdmin
              SystemAdmin
              1215 Posts
              ACCEPTED ANSWER

              Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

              ‏2006-02-12T07:23:48Z  in response to SystemAdmin
              According to the attached article the DataSource cannot be looked up from a spun off thread.
              Does it mean that the Spring framework cannot be used with Websphere?
              Spring connects to the datasource from its own thread.

              rad6 user
              • SystemAdmin
                SystemAdmin
                1215 Posts
                ACCEPTED ANSWER

                Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

                ‏2006-03-07T21:28:28Z  in response to SystemAdmin
                Anyone have any information on this question? I have my JNDI lookups working fine for the main thread, but we have some user threads in our application and they are throwing NamingExceptions. It appears that the last poster is correct and user threads can't access the JNDI context that the application server can. How do I fix this?
                Thanks.
                • SystemAdmin
                  SystemAdmin
                  1215 Posts
                  ACCEPTED ANSWER

                  My solution (this problem is about JNDI for background threads, but not JNDI in jsp/servlet!!)

                  ‏2006-06-26T08:53:46Z  in response to SystemAdmin
                  I met the same problem as you.

                  This problem is about "JNDI for background threads", but not "JNDI in jsp/servlet"!!
                  The problems of JNDI in jsp/servlet can be solved by adding the resource definition in web.xml.
                  But the problem of JNDI for background threads can not be solved if codes not changed!

                  Altogether, there are 3 solutions of the problem of JNDI for background threads.

                  1) Someone replied above: use the bare "jdbc/DBNAME", without "java:comp/env/".
                  This solution is dangerous and will cause many error logs.
                  It should be not suggested.

                  2) Use direct connection, but not JNDI.
                  For example:

                  Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
                  conn = DriverManager.getConnection(url,user,password);

                  This is a bad solution. Because it means hard codes, and the DB connection parameters have to be determined when write codes.
                  3) Pass JNDI from jsp/servlet to the background threads.

                  Some above replier has given us the following link:
                  http://www-1.ibm.com/support/docview.wss?uid=swg21168795
                  This technote tells us clearly

                  Do not execute the lookup in a separate thread, because there is no way to "give" a spun-off thread any context. Modify the code so that it does not perform a java: lookup or attempt to get an InitialContext in a thread spun-off by a servlet or JSP.


                  The key reason is "no context" for the spun-off thread.
                  So why not pass through JNDI from jsp/servlet to the target threads?

                  I verified this solution. It works well in my application.
                  The example codes are like the following:


                  invoke thread from a servlet

                  public class AutoMonitor extends HttpServlet implements Servlet {

                  private final Timer = new Timer();

                  public void destroy() {
                  timer.cancel();
                  }
                  public static DataSource getDataSource(String jndiName){
                  DataSource ds =null;
                  try {
                  Context ctx = new InitialContext();
                  ds = (DataSource)ctx.lookup("java:comp/env/" + jndiName);
                  } catch(Exception e) {
                  e.printStackTrace();
                  }
                  return ds;
                  }

                  public void init(ServletConfig conf) throws ServletException {
                  super.init(conf);

                  DataSource ds = this.getDataSource("jdbc/mydb");

                  AutoTask aatask = new AutoTask();
                  aatask.setDataSource(ds);
                  aatask.run();
                  }
                  Background thread running with JNDI connection

                  public class AutoTask {
                  private DataSource ds = null;

                  public void setDataSource(DataSource d){
                  ds = d;
                  }

                  public void run() {
                  Connection conn = null;
                  PreparedStatement ps = null;
                  ResultSet rs = null;
                  try{
                  conn = ds.getConnection();

                  ......
              • SystemAdmin
                SystemAdmin
                1215 Posts
                ACCEPTED ANSWER

                Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

                ‏2007-02-08T17:20:59Z  in response to SystemAdmin
                Datasource lookup can be done with the Spring framework. The datasource JNDI name should be present in the ibm-web-bnd.xmi for the JndiObjectFactoryBean (Spring class) to instantiate properly.

                if you are using RAD/WSAD, open up web.xml, go to Resources, select your reference and add the name in "Websphere bindings" JNDI Name field. The JNDI name should be same as the reference. This step will add an entry in ibm-web-bnd.xmi file

                <resRefBindings xmi:id="ResourceRefBinding_1170953822670" jndiName="jdbc/<jndi_name>">
                <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1170953822670"/>
                </resRefBindings>

                This step will make sure that the datasource is found under java:comp/env
        • SystemAdmin
          SystemAdmin
          1215 Posts
          ACCEPTED ANSWER

          Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

          ‏2005-07-07T02:20:14Z  in response to SystemAdmin
          I have the same problem with you. Can you tell me how you solve it? My email address is hecz@itpub.net
        • SystemAdmin
          SystemAdmin
          1215 Posts
          ACCEPTED ANSWER

          Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

          ‏2005-07-07T03:23:33Z  in response to SystemAdmin
          I think the following two page can solve your problem!

          http://www-1.ibm.com/support/docview.wss?uid=swg21175742
          http://www-1.ibm.com/support/docview.wss?uid=swg21168795
        • SystemAdmin
          SystemAdmin
          1215 Posts
          ACCEPTED ANSWER

          Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

          ‏2005-10-19T18:36:12Z  in response to SystemAdmin
          heii.. i got the same problem, now it is resolved.

          create an alia name for your jndi through web.xml and try again, it should work...

          if any problems further, mail me back srmselva@yahoo.com
        • SystemAdmin
          SystemAdmin
          1215 Posts
          ACCEPTED ANSWER

          Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

          ‏2006-03-07T10:23:59Z  in response to SystemAdmin
          I have the same issue. did u have any fix for it?
          If so please let me know.

          Thanks
          shanmugam.ve
          • SystemAdmin
            SystemAdmin
            1215 Posts
            ACCEPTED ANSWER

            Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

            ‏2006-03-07T21:25:31Z  in response to SystemAdmin
            I had the same problem with the deprecated warnings. I fixed it by doing the following.

            Data sources should be looked up using the alias name you have defined, but then prefixed with java:comp/env. You can create data sources either through the admin site or through the RAD IDE by opening up the web.xml.

            1. Create a datasource named: MYDataSourceDB
            2. Create it with the JNDI name of: jdbc/OraclePooledQa (this name is specific to my application server - Orion). Yours might be different.
            3. Lookup for the database is done by:
            ds = (DataSource) initialContext.lookup(java:comp/env/MYDataSourceDB)

            NOTE: #3 and #1 are tsame, just in #3 it's prefixed with java:comp/env/
            Hope that helps.
            • SystemAdmin
              SystemAdmin
              1215 Posts
              ACCEPTED ANSWER

              Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

              ‏2006-04-11T09:50:28Z  in response to SystemAdmin
              great!

              The key is to use resource reference name.
            • SystemAdmin
              SystemAdmin
              1215 Posts
              ACCEPTED ANSWER

              Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

              ‏2006-04-26T15:06:11Z  in response to SystemAdmin
              I've tried it like that, but it does not help :(
            • SystemAdmin
              SystemAdmin
              1215 Posts
              ACCEPTED ANSWER

              Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

              ‏2006-04-26T16:23:17Z  in response to SystemAdmin
              I've solved the problem on my side:

              I had to look up with the pure datasource JNDI name (without any prefix!) like that:
              jdbc/OraclePooledQa

              No "java:comp/env" before...

              The lookup is being done from Hibernate, so I have something like the following in my hibernate.cfg.xml file:

              <property name="connection.datasource">
              jdbc/OraclePooledQa
              </property>

              Regards,
              Andrey
      • SystemAdmin
        SystemAdmin
        1215 Posts
        ACCEPTED ANSWER

        Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

        ‏2006-04-26T15:08:06Z  in response to SystemAdmin
        I've tried to change web.xml as well as ibm-web-bnd.xmi as it was suggested, but it gave no success... Any suggestions?
        • SystemAdmin
          SystemAdmin
          1215 Posts
          ACCEPTED ANSWER

          Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

          ‏2007-07-25T14:47:18Z  in response to SystemAdmin
          I did tried with Spring Framework but still Im able to get the datasource as java:comp/env/dsName. So even if Spring manages with its own thread it can still find the resource reference.
    • Sreenivas_Tummala
      Sreenivas_Tummala
      1 Post
      ACCEPTED ANSWER

      Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

      ‏2005-10-27T15:34:45Z  in response to SystemAdmin
      Hi All!

      If you are using RAD or WSAD, open your web.xml and go to References Tab, select your referene (i.e., datasource). In Websphere Bindings section enter the jndi name of the datasource (jdbc/yourdatasourcename), check Use default method and enter Authentication alias as entered while creating the datasource (like DB2ADMIN / USER / SCOT etc.,) and restart your server.

      Thanks and Regards
      Tummala Sreenivas
      Singapore
      • SystemAdmin
        SystemAdmin
        1215 Posts
        ACCEPTED ANSWER

        Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

        ‏2006-05-02T13:38:17Z  in response to Sreenivas_Tummala
        Here is the detailed solution:
        I was facing the same problem and came across with this thread.
        I found the solution, solved it and thought would share with you all.

        1. you can remove "java:comp/env/" part. It will work, but you will get the following warning..
        I J2CA0122I: Resource reference jdbc/myDataSource could not be located, so default values of the following are used: Resource-ref settings

        2. Good thing is to create reference alias
        have a look at this link for detailed solution.. it worked for me
        http://www.webspherepower.com/issuesprint/issue200410/00001357.html
      • SystemAdmin
        SystemAdmin
        1215 Posts
        ACCEPTED ANSWER

        Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

        ‏2006-05-29T23:59:01Z  in response to Sreenivas_Tummala
        HI ,,

        i am trying to lookup DataSource from my entity bean ,but when i run it on UTC it gives me this Exception , can u help me with this.

        Bean method

        try{
        InitialContext jndiContext = new InitialContext();
        DataSource dataSource = (DataSource)jndiContext.lookup
        ("java:comp/env/jdbc/TECHBOOK");

        return dataSource.getConnection();
        }

        in EJB diployment des


        i have

        JNDI - CMP Connection Factory Binding
        JNDI Name - jdbc/TECHBOOK

        i have a reference

        name - TechbookDS

        under , WebSphere Bindings

        JNDI name - jdbc/TECHBOOK

        ,,,, when i deploy this on UTC , it give me this error ,

        E CNTR0019E: Non-application exception occurred while processing method "create". Exception data: com.ibm.ejs.container.CreateFailureException: ; nested exception is:
        javax.ejb.EJBException: nested exception is: javax.naming.NameNotFoundException: Name "comp/env/TECHBOOK" not found in context "java:".
        can u please tell me what should do for this
      • Jeuz
        Jeuz
        1 Post
        ACCEPTED ANSWER

        Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

        ‏2010-09-15T03:08:55Z  in response to Sreenivas_Tummala
        Hello,
        What if I do not have RAD or WSAD? I use Eclipse and edited the web.xml there adding a resource-ref element. Also, I read that you also need to configure somthing in the ibm-web-bnd.xmi for jndi to work. Can I do that in Eclipse too? Thanks.

        Jeuz
        Philippines
    • migselv46
      migselv46
      1 Post
      ACCEPTED ANSWER

      Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

      ‏2006-07-18T21:33:22Z  in response to SystemAdmin
      This also solved my problem
  • SystemAdmin
    SystemAdmin
    1215 Posts
    ACCEPTED ANSWER

    Re: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".

    ‏2008-07-17T15:40:08Z  in response to SystemAdmin
    Hi,

    I found my problem. Via IBM RAD tool, from my web application, click WebDeployment Description, click References tab, the name datasource name was TestDataSource1, it should be jdbc/TestDataSource1. Once I added jdbc/, then view web.xml source, you can see if fixed as:
    <res-ref-name>jdbc/TestDataSource1</res-ref-name>. Then the java code can find that datasource.

    Also make sure that WebDeployment description screen, WebSphere binding JNDI name also has jdbc/TestDataSource1 in it.