404: Page not found


General J2EE: question about jndi for datasource

  1. question about jndi for datasource (7 messages)


    i setup a connection pool named "TaskPool" in my weblogic server,the i setup a datasource named "dsTaskPool" to point to it,in my project,i lookup it by following:

    Context ctx=new InitialContext();
    DataSource ds=(dataSource)ctx.lookup("dsTaskPool");

    it works well.

    but if i use following method:

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

    it throws:

    javax.naming.NameNotFoundException: Unable to resolve comp/env/dsTaskPool/ Resolved: 'comp/env' Unresolved:'dsTaskPool' ; remaining name ''

    at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:887)

    at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:219)

    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:183)

    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)

    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)

    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:339)

    at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:36)

    at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:124)

    at javax.naming.InitialContext.lookup(InitialContext.java:350)

    at com.jhtop.task.forum.InitServlet.init(InitServlet.java:35)

    at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:700)

    at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:643)

    at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:588)

    at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:2221)

    at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:2165)

    at weblogic.servlet.internal.HttpServer.preloadServlets(HttpServer.java:475)

    at weblogic.servlet.internal.WebService.preloadServlets(WebService.java:450)

    at weblogic.t3.srvr.ServletInitRunner.run(ServletInitRunner.java:49)

    at java.lang.Thread.run(Thread.java:484)

    help me!thank you!
  2. question about jndi for datasource[ Go to top ]

    I think it should be:

    java:comp/env/jdbc/dsTaskPool as opposed to java:comp/env/dsTaskPool

  3. question about jndi for datasource[ Go to top ]

    Putting a DataSource in the jdbc context is a recommendation in the spec, but not a requirement. It work fine to put it directly in java:comp/env/ directly.

    See section in the EJB 2.0 spec.

  4. question about jndi for datasource[ Go to top ]


    I found the same "feature" in WLS 6.1 SP3 earlier today! And I think the "java:comp/env/dsTaskPool" lookup should work. I will check some old code for JRun and OC4J tomorrow!

  5. i think Mr. Obi Orjiekwe is right as the T3 server prefixes that JDBC as that should work. Simulated this by creating a datasource under JDBC...(a quick fix and look for the original work around)
  6. hello
    i have tried all of the possibilities,whether"java:comp/env/dsTaskPool" or "java:comp/env/jdbc/dsTaskPool",detail as following:

    start weblogic6.01,launch ie6.0,browser to "http://localhost:7001/console",in the console,select the connection pool,input the driver and url,in the name text box,i input "TaskPool",then select datasource,in the name text box,i input "dsTaskPool",in the connection pool box,i point to "TaskPool".

    according to my discription,i think the "java:comp/env/dsTaskPool" should be used in my code to look up datasource.if you want to use "java:comp/env/jdbc/dsTaskPool",you must input "jdbc/dsTaskPool" in the text box of the weblogic console.

    the strange thing is whether i use which name,it don't work,but if i use ctx.lookup("dsTaskPool"),it works well.

    do you think i miss something?maybe my code is not complete?

    help me!
    thank you!
  7. question about jndi for datasource[ Go to top ]


    Now I have checked some other projects using JRun and OC4J. I have found that the lookup used was ctx.lookup("java:comp/env/dsTaskPool"), and the configuration on the server was just "dsTaskPool". (With or without the jdbc sub-context...) The "java:comp/env/dsTaskPool" syntax is also used in sample code in the EJB 2.0 spec.

    What does this mean for portability of EJB:s (using DataSource references) developed on WLS 6.1???

  8. Hi
    look for "dsTaskPool" where its placed after its created.. and the lookup is the path/"dsTaskPool".Standards in the project might be placing it under a directory. hope this helps..