I think that the context is ok bacause the  log file (catalina.out) tells me:

[DEBUG] InitialContext = javax.naming.InitialContext@46110f9b
[DEBUG] lookup java:comp/env = org.apache.naming.NamingContext@3700f9b
[DEBUG] Datasource = Resource reference to a factory for java.sql.Connection
    instances that may be used for talking to a particular
    database that is configured in the server.xml file.

So ds isn't empty: the exception is thrown when I call:

Connection con =  ds.getConnection();

The Datasource is Tomcat's Datasource ( I have followed jndi tutorial)


Laura





Alle 18:54, luned́ 15 aprile 2002, hai scritto:
> Put a break point in between and examine Context and its contents. Also
> check the spelling/case of datasource "lookup" name. If you are creating
> the Datasource yourself, check for any exceptions during its registration.
> If the DS is on an application server, talk to your Server admin.
>
> regards
> hemant
>
>
>
> ----- Original Message -----
> From: "Laura" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Monday, April 15, 2002 12:25 PM
> Subject: PLEASE HELP ME: JNDI ERROR 1
>
> > Other information because I don't know what to do.
> >
> > The exception is created when I call my function getConnection(). The
> > code
>
> is
>
> > when I execute "con =  ds.getConnection();".
> >
> > The code is:
> >
> > static {
> >     try  {
> >         Context initCtx = new InitialContext();
> >         System.out.println("[DEBUG] Dopo l'InitialContext = " +
> > initCtx.toString());
> >         Context envCtx = (Context) initCtx.lookup("java:comp/env");
> >         System.out.println("[DEBUG] Dopo lookup java:comp/env = " +
> > envCtx.toString());
> >         DataSource ds = (DataSource) envCtx.lookup(dbName);
> >         System.out.println("[DEBUG] Datasource = " + ds.toString());
> >         con =  ds.getConnection();
> >         if (con == null)
> >           System.out.println("[ERROR] Connessione nulla");
> >       } catch (Exception ex) {
> >         System.out.println("[ERROR] Errore = "  + ex.toString() + " \n" +
> > ex.getMessage());
> >         con = null;
> >       }
> >   }
> >
> >
> > protected synchronized Connection getConnection() {
> >          while (conFree == false) {
> >             try {
> >                wait();
> >             } catch (InterruptedException e) {
> >               System.out.println("[ERROR] Eccezione nella getConnection()
>
> = "
>
> > + e.toString());
> >             }
> >          }
> >          conFree = false;
> >          System.out.println("[DEBUG] Punto 1");
> >          notify();
> >          System.out.println("[DEBUG] Punto 2");
> >          return con;
> >     }
> >
> >
> >
> > Please help me.
> > Before this code was ok. Has someone some idea?
> >
> > Help.
> >
> >
> > Laura
> >
> >
> > --
> > To unsubscribe:   <mailto:[EMAIL PROTECTED]>
> > For additional commands: <mailto:[EMAIL PROTECTED]>
> > Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to