5 Replies Latest reply on Aug 18, 2007 3:13 PM by jaikiran pai

    JNDI and DefaultDS

    axel becker Newbie

      Hi,

      i have downloaded the latest stable version of jboss application server (4.2.1.GA Stable 90 MB 2007-07-16)

      After that i have build a small webapplication which contains a ServletContextListener.

      Now i want to lookup the DefaultDS in the "contextInitialized"-Method of my ServletContextListener, but i allways get a "NameNotBoundException". I tried a lot of JNDI-Names ("java:DefaultDS" "java:/DefaultDS" "java:comp/env/jdbc/DefaultDS")

      I dont make any changes on the jboss configuration! During the startup i get this information:

      23:06:00,758 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=Data
      SourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
      



      I have no ideas, how to solve this problem :-(

      Bye, Axel

        • 1. Re: JNDI and DefaultDS
          wayne baylor Apprentice

          could you provide the code you're using to do the lookup?

          • 2. Re: JNDI and DefaultDS
            axel becker Newbie

             

            "waynebaylor" wrote:
            could you provide the code you're using to do the lookup?


            i use the this two rows:

            InitialContext ic = new InitialContext();
            ic.lookup("java:/DefaultDS");
            


            • 3. Re: JNDI and DefaultDS
              wayne baylor Apprentice

              the lookup looks good.

              maybe try printing out the contents of

              new InitialContext().getEnvironment();

              the context should contain the equivalent of doing this:
              Properties p = new Properties();
               p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
               p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
               p.put(Context.PROVIDER_URL, "localhost:1099");
              
              Context ctx = new InitialContext(p);


              • 4. Re: JNDI and DefaultDS
                axel becker Newbie

                 

                new InitialContext().getEnvironment();


                returns this map:

                {java.naming.provider.url=localhost:1099, java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces}
                


                i tried a new datasource too. (MySQLDS from the conf-folder). Its the same problem.

                i use windows vista. maybe this is the cause of this problem...

                • 5. Re: JNDI and DefaultDS
                  jaikiran pai Master

                   

                  "axel.becker" wrote:

                  After that i have build a small webapplication which contains a ServletContextListener.

                  Now i want to lookup the DefaultDS in the "contextInitialized"-Method of my ServletContextListener


                  Instead of looking it up from the ServletContextListener, try looking it up from a servlet/jsp and see if that works. That might give us a clue as to whether the ServletContextListener is being called even before the datasource is bound to the JNDI tree