1 Reply Latest reply on Mar 21, 2008 10:46 AM by R M

    [JBoss 4.0.2] NameNotFoundException: datasource not bound

    R M Newbie

      I have not trivial problem with looking up datasource. Some details:

      xxx-ds.xml datasource entry:

       <jndi-name>jdbc/cms</jndi-name> <connection-url>jdbc:mysql://localhost:3306/mydb?useUnicode=true&characterEncoding=latin2</connection-url>

      web.xml entry:
       <description>CMS Datasource</description>

      jboss-web.xml entry:

      Code that does lookup:
      InitialContext initctx = new InitialContext();

      This code works in most cases well (within EJB module, web app, etc) but I have problem in one special case: I have servlet (let call it JobInitializerServlet) that uses Quartz to schedule some jobs.
      This servlet uses my class QuartzManager to find all jobs in database and schedule them. Single job is just a single EJB which "have to be loaded" from db with EJB.load() method.
      Load method uses his own DAO class, where is done datasource lookup using code above. So QuartzManager calls EJB and EJB internally calls lookup of DS.

      And there is a problem:
      javax.naming.NameNotFoundException: cms not bound
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
       at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
       at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:278)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
       at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:701)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at javax.naming.InitialContext.lookup(InitialContext.java:392)

      As I can say, I tried to do same DS lookup in JobInitializerServlet before calling QuartzManager and it works! But a while later (in QuartzManager code) looking up DS fails. Why???

        • 1. Re: [JBoss 4.0.2] NameNotFoundException: datasource not boun
          R M Newbie

          Adding some more info about JobInitializerServlet:
          code is within init() method of the servlet (maybe it does matter?), something like that:

          public void init(ServletConfig config) throws ServletException {
           String lookupName = "java:comp/env/jdbc/cms";
           //this code works!
           try {
           InitialContext ctx = new InitialContext();
           } catch (Exception e) {
           log.error("Error looking up " + lookupName, e);
           //this code inside manager doesn't work!
           try {
           } catch (Exception exc) {
           log.error("Error initializing quartz job's manager! ");