Datasource JNDI lookup failing

2002-07-19 Thread Adam Lipscombe

Folks,

I am having a problem trying to lookup a Database connection from JNDI with
Tomcat 4.0.4 on Debian Linux.
My code is:

Connection con = null;

System.out.println(instantiating database connection );

try
{
  System.out.println(getting InitialContext);
  Context ctx = new InitialContext();
  System.out.println(got InitialContext);

  // Print out bindings to make sure its there
  NamingEnumeration e = ctx.list(java:comp/env/jdbc);
  while(true == e.hasMore())
  {
System.out.println(enumeration name =  + e.next());
  }

  // Get JDBC context
  System.out.println(getting JDBC context);
  Context jdbcContext = (Context) ctx.lookup(java:comp/env/jdbc);
  System.out.println(got jdbcContext);

  // Look up our data source
  System.out.println(looking up insuranceAdminTest);
  DataSource ds = (DataSource) jdbcContext.lookup(insuranceAdminTest);
  System.out.println(got DataSource);

  con = ds.getConnection();
  System.out.println(got connection);
}
catch (NamingException ex)
{
  System.err.println(failed to obtain JNDI context);
  throw new HalvorException(failed to obtain JNDI context, ex);
}
catch (SQLException ex)
{
  System.err.println(failed to open database connection);
  throw new HalvorException(failed to open database connection, ex);
}


The output from the above is:

instantiating database connection
getting InitialContext
got InitialContext
enumeration name = insuranceAdminTest: org.apache.naming.ResourceRef
getting JDBC context
got jdbcContext
looking up insuranceAdminTest
failed to obtain JNDI context


The server.xml snippet is:

Resource name=jdbc/insuranceAdminTest auth=CONTAINER
  type=javax.sql.DataSource/
  ResourceParams name=jdbc/insuranceAdminTest
parameternameuser/namevaluehalvor/value/parameter
parameternamepassword/namevaluehalvor/value/parameter

parameternamedriverClassName/namevalueorg.gjt.mm.mysql.Driver/value
/parameter

parameternamedriverName/namevaluejdbc:mysql:///InsuranceAdminTest/v
alue/parameter
  /ResourceParams

the web.xml snippet is:

  resource-ref
res-ref-namejdbc/insuranceAdminTest/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth



What I dont understand is that the line that prints enumeration name = 
find the insuranceAdminTest binding, but the subsequent lookup on the
jdbcContext Context fails...




Does anyone know what is wrong?


Many thanks - Adam Lipscombe



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Datasource JNDI lookup failing

2002-07-19 Thread Turner, John


I've had the exact same problem with for the past couple of weeks, only with
the Microsoft Type4 SQL Server driver.  Everything seems to work great, and
the Context is definitely found, but the DataSource is always null.

I haven't been able to find a solution, the closest I came was going to
4.1.7, but I can't do that until it is officially released (my client has a
no betas restriction for production apps).

If anyone knows for sure how to get around this problem using current
production versions, I would love to know about it.

John Turner
[EMAIL PROTECTED]


-Original Message-
From: Adam Lipscombe [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 7:57 AM
To: Tomcat Users Mailing List
Subject: Datasource JNDI lookup failing


Folks,

I am having a problem trying to lookup a Database connection from JNDI with
Tomcat 4.0.4 on Debian Linux.
My code is:

Connection con = null;

System.out.println(instantiating database connection );

try
{
  System.out.println(getting InitialContext);
  Context ctx = new InitialContext();
  System.out.println(got InitialContext);

  // Print out bindings to make sure its there
  NamingEnumeration e = ctx.list(java:comp/env/jdbc);
  while(true == e.hasMore())
  {
System.out.println(enumeration name =  + e.next());
  }

  // Get JDBC context
  System.out.println(getting JDBC context);
  Context jdbcContext = (Context) ctx.lookup(java:comp/env/jdbc);
  System.out.println(got jdbcContext);

  // Look up our data source
  System.out.println(looking up insuranceAdminTest);
  DataSource ds = (DataSource) jdbcContext.lookup(insuranceAdminTest);
  System.out.println(got DataSource);

  con = ds.getConnection();
  System.out.println(got connection);
}
catch (NamingException ex)
{
  System.err.println(failed to obtain JNDI context);
  throw new HalvorException(failed to obtain JNDI context, ex);
}
catch (SQLException ex)
{
  System.err.println(failed to open database connection);
  throw new HalvorException(failed to open database connection, ex);
}


The output from the above is:

instantiating database connection
getting InitialContext
got InitialContext
enumeration name = insuranceAdminTest: org.apache.naming.ResourceRef
getting JDBC context
got jdbcContext
looking up insuranceAdminTest
failed to obtain JNDI context


The server.xml snippet is:

Resource name=jdbc/insuranceAdminTest auth=CONTAINER
  type=javax.sql.DataSource/
  ResourceParams name=jdbc/insuranceAdminTest
parameternameuser/namevaluehalvor/value/parameter
parameternamepassword/namevaluehalvor/value/parameter

parameternamedriverClassName/namevalueorg.gjt.mm.mysql.Driver/value
/parameter

parameternamedriverName/namevaluejdbc:mysql:///InsuranceAdminTest/v
alue/parameter
  /ResourceParams

the web.xml snippet is:

  resource-ref
res-ref-namejdbc/insuranceAdminTest/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth



What I dont understand is that the line that prints enumeration name = 
find the insuranceAdminTest binding, but the subsequent lookup on the
jdbcContext Context fails...




Does anyone know what is wrong?


Many thanks - Adam Lipscombe



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Datasource JNDI lookup failing

2002-07-19 Thread Vikramjit Singh

I had a similar problem, but i was using classes12.zip that is from Oracle.
I tried every option, but it didnt seem to work. Then at the end upgraded to
tc 4.1.7. TC 4.1.7 had all the included files, and got the DataSource and
the connection.
My advice, upgrade to TC 4.1.7 (AFAIK) it has much better support for JNDI.
Anyways there has been a lot of discussion about this in the past weeks. You
could check out the archives also. Check this link also.

http://marc.theaimsgroup.com/?l=tomcat-userm=102225547106556w=2

Regards,
Vikramjit Singh,
Systems Engineer,
GTL Ltd.
Ph. 7612929-1059


-Original Message-
From: Turner, John [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 5:05 AM
To: 'Tomcat Users List'
Subject: RE: Datasource JNDI lookup failing



I've had the exact same problem with for the past couple of weeks, only with
the Microsoft Type4 SQL Server driver.  Everything seems to work great, and
the Context is definitely found, but the DataSource is always null.

I haven't been able to find a solution, the closest I came was going to
4.1.7, but I can't do that until it is officially released (my client has a
no betas restriction for production apps).

If anyone knows for sure how to get around this problem using current
production versions, I would love to know about it.

John Turner
[EMAIL PROTECTED]


-Original Message-
From: Adam Lipscombe [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 7:57 AM
To: Tomcat Users Mailing List
Subject: Datasource JNDI lookup failing


Folks,

I am having a problem trying to lookup a Database connection from JNDI with
Tomcat 4.0.4 on Debian Linux.
My code is:

Connection con = null;

System.out.println(instantiating database connection );

try
{
  System.out.println(getting InitialContext);
  Context ctx = new InitialContext();
  System.out.println(got InitialContext);

  // Print out bindings to make sure its there
  NamingEnumeration e = ctx.list(java:comp/env/jdbc);
  while(true == e.hasMore())
  {
System.out.println(enumeration name =  + e.next());
  }

  // Get JDBC context
  System.out.println(getting JDBC context);
  Context jdbcContext = (Context) ctx.lookup(java:comp/env/jdbc);
  System.out.println(got jdbcContext);

  // Look up our data source
  System.out.println(looking up insuranceAdminTest);
  DataSource ds = (DataSource) jdbcContext.lookup(insuranceAdminTest);
  System.out.println(got DataSource);

  con = ds.getConnection();
  System.out.println(got connection);
}
catch (NamingException ex)
{
  System.err.println(failed to obtain JNDI context);
  throw new HalvorException(failed to obtain JNDI context, ex);
}
catch (SQLException ex)
{
  System.err.println(failed to open database connection);
  throw new HalvorException(failed to open database connection, ex);
}


The output from the above is:

instantiating database connection
getting InitialContext
got InitialContext
enumeration name = insuranceAdminTest: org.apache.naming.ResourceRef
getting JDBC context
got jdbcContext
looking up insuranceAdminTest
failed to obtain JNDI context


The server.xml snippet is:

Resource name=jdbc/insuranceAdminTest auth=CONTAINER
  type=javax.sql.DataSource/
  ResourceParams name=jdbc/insuranceAdminTest
parameternameuser/namevaluehalvor/value/parameter
parameternamepassword/namevaluehalvor/value/parameter

parameternamedriverClassName/namevalueorg.gjt.mm.mysql.Driver/value
/parameter

parameternamedriverName/namevaluejdbc:mysql:///InsuranceAdminTest/v
alue/parameter
  /ResourceParams

the web.xml snippet is:

  resource-ref
res-ref-namejdbc/insuranceAdminTest/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth



What I dont understand is that the line that prints enumeration name = 
find the insuranceAdminTest binding, but the subsequent lookup on the
jdbcContext Context fails...




Does anyone know what is wrong?


Many thanks - Adam Lipscombe



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Datasource JNDI lookup failing

2002-07-19 Thread Turner, John


Thanks for the reply, I've tried the solution in that link.  As I said,
nothing has worked, and I am unable to use anything past 4.0.4 until it is
officially released (not beta).

John Turner
[EMAIL PROTECTED]


-Original Message-
From: Vikramjit Singh [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 8:16 AM
To: 'Tomcat Users List'
Subject: RE: Datasource JNDI lookup failing


I had a similar problem, but i was using classes12.zip that is from Oracle.
I tried every option, but it didnt seem to work. Then at the end upgraded to
tc 4.1.7. TC 4.1.7 had all the included files, and got the DataSource and
the connection.
My advice, upgrade to TC 4.1.7 (AFAIK) it has much better support for JNDI.
Anyways there has been a lot of discussion about this in the past weeks. You
could check out the archives also. Check this link also.

http://marc.theaimsgroup.com/?l=tomcat-userm=102225547106556w=2

Regards,
Vikramjit Singh,
Systems Engineer,
GTL Ltd.
Ph. 7612929-1059


-Original Message-
From: Turner, John [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 5:05 AM
To: 'Tomcat Users List'
Subject: RE: Datasource JNDI lookup failing



I've had the exact same problem with for the past couple of weeks, only with
the Microsoft Type4 SQL Server driver.  Everything seems to work great, and
the Context is definitely found, but the DataSource is always null.

I haven't been able to find a solution, the closest I came was going to
4.1.7, but I can't do that until it is officially released (my client has a
no betas restriction for production apps).

If anyone knows for sure how to get around this problem using current
production versions, I would love to know about it.

John Turner
[EMAIL PROTECTED]


-Original Message-
From: Adam Lipscombe [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 7:57 AM
To: Tomcat Users Mailing List
Subject: Datasource JNDI lookup failing


Folks,

I am having a problem trying to lookup a Database connection from JNDI with
Tomcat 4.0.4 on Debian Linux.
My code is:

Connection con = null;

System.out.println(instantiating database connection );

try
{
  System.out.println(getting InitialContext);
  Context ctx = new InitialContext();
  System.out.println(got InitialContext);

  // Print out bindings to make sure its there
  NamingEnumeration e = ctx.list(java:comp/env/jdbc);
  while(true == e.hasMore())
  {
System.out.println(enumeration name =  + e.next());
  }

  // Get JDBC context
  System.out.println(getting JDBC context);
  Context jdbcContext = (Context) ctx.lookup(java:comp/env/jdbc);
  System.out.println(got jdbcContext);

  // Look up our data source
  System.out.println(looking up insuranceAdminTest);
  DataSource ds = (DataSource) jdbcContext.lookup(insuranceAdminTest);
  System.out.println(got DataSource);

  con = ds.getConnection();
  System.out.println(got connection);
}
catch (NamingException ex)
{
  System.err.println(failed to obtain JNDI context);
  throw new HalvorException(failed to obtain JNDI context, ex);
}
catch (SQLException ex)
{
  System.err.println(failed to open database connection);
  throw new HalvorException(failed to open database connection, ex);
}


The output from the above is:

instantiating database connection
getting InitialContext
got InitialContext
enumeration name = insuranceAdminTest: org.apache.naming.ResourceRef
getting JDBC context
got jdbcContext
looking up insuranceAdminTest
failed to obtain JNDI context


The server.xml snippet is:

Resource name=jdbc/insuranceAdminTest auth=CONTAINER
  type=javax.sql.DataSource/
  ResourceParams name=jdbc/insuranceAdminTest
parameternameuser/namevaluehalvor/value/parameter
parameternamepassword/namevaluehalvor/value/parameter

parameternamedriverClassName/namevalueorg.gjt.mm.mysql.Driver/value
/parameter

parameternamedriverName/namevaluejdbc:mysql:///InsuranceAdminTest/v
alue/parameter
  /ResourceParams

the web.xml snippet is:

  resource-ref
res-ref-namejdbc/insuranceAdminTest/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth



What I dont understand is that the line that prints enumeration name = 
find the insuranceAdminTest binding, but the subsequent lookup on the
jdbcContext Context fails...




Does anyone know what is wrong?


Many thanks - Adam Lipscombe



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Datasource JNDI lookup failing

2002-07-19 Thread Ben Walding

Check that you have Tyrex in your tomcat install, the light edition 
doesn't include it (from memory).  Also have a look through past 
messages about some Naming* classes being missing from the RPM versions 
of TomCat

Turner, John wrote:

Thanks for the reply, I've tried the solution in that link.  As I said,
nothing has worked, and I am unable to use anything past 4.0.4 until it is
officially released (not beta).

John Turner
[EMAIL PROTECTED]


-Original Message-
From: Vikramjit Singh [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 8:16 AM
To: 'Tomcat Users List'
Subject: RE: Datasource JNDI lookup failing


I had a similar problem, but i was using classes12.zip that is from Oracle.
I tried every option, but it didnt seem to work. Then at the end upgraded to
tc 4.1.7. TC 4.1.7 had all the included files, and got the DataSource and
the connection.
My advice, upgrade to TC 4.1.7 (AFAIK) it has much better support for JNDI.
Anyways there has been a lot of discussion about this in the past weeks. You
could check out the archives also. Check this link also.

http://marc.theaimsgroup.com/?l=tomcat-userm=102225547106556w=2

Regards,
Vikramjit Singh,
Systems Engineer,
GTL Ltd.
Ph. 7612929-1059


-Original Message-
From: Turner, John [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 5:05 AM
To: 'Tomcat Users List'
Subject: RE: Datasource JNDI lookup failing



I've had the exact same problem with for the past couple of weeks, only with
the Microsoft Type4 SQL Server driver.  Everything seems to work great, and
the Context is definitely found, but the DataSource is always null.

I haven't been able to find a solution, the closest I came was going to
4.1.7, but I can't do that until it is officially released (my client has a
no betas restriction for production apps).

If anyone knows for sure how to get around this problem using current
production versions, I would love to know about it.

John Turner
[EMAIL PROTECTED]


-Original Message-
From: Adam Lipscombe [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 7:57 AM
To: Tomcat Users Mailing List
Subject: Datasource JNDI lookup failing


Folks,

I am having a problem trying to lookup a Database connection from JNDI with
Tomcat 4.0.4 on Debian Linux.
My code is:

Connection con = null;

System.out.println(instantiating database connection );

try
{
  System.out.println(getting InitialContext);
  Context ctx = new InitialContext();
  System.out.println(got InitialContext);

  // Print out bindings to make sure its there
  NamingEnumeration e = ctx.list(java:comp/env/jdbc);
  while(true == e.hasMore())
  {
System.out.println(enumeration name =  + e.next());
  }

  // Get JDBC context
  System.out.println(getting JDBC context);
  Context jdbcContext = (Context) ctx.lookup(java:comp/env/jdbc);
  System.out.println(got jdbcContext);

  // Look up our data source
  System.out.println(looking up insuranceAdminTest);
  DataSource ds = (DataSource) jdbcContext.lookup(insuranceAdminTest);
  System.out.println(got DataSource);

  con = ds.getConnection();
  System.out.println(got connection);
}
catch (NamingException ex)
{
  System.err.println(failed to obtain JNDI context);
  throw new HalvorException(failed to obtain JNDI context, ex);
}
catch (SQLException ex)
{
  System.err.println(failed to open database connection);
  throw new HalvorException(failed to open database connection, ex);
}


The output from the above is:

instantiating database connection
getting InitialContext
got InitialContext
enumeration name = insuranceAdminTest: org.apache.naming.ResourceRef
getting JDBC context
got jdbcContext
looking up insuranceAdminTest
failed to obtain JNDI context


The server.xml snippet is:

Resource name=jdbc/insuranceAdminTest auth=CONTAINER
  type=javax.sql.DataSource/
  ResourceParams name=jdbc/insuranceAdminTest
parameternameuser/namevaluehalvor/value/parameter
parameternamepassword/namevaluehalvor/value/parameter

parameternamedriverClassName/namevalueorg.gjt.mm.mysql.Driver/value
  

/parameter



parameternamedriverName/namevaluejdbc:mysql:///InsuranceAdminTest/v
alue/parameter
  /ResourceParams

the web.xml snippet is:

  resource-ref
res-ref-namejdbc/insuranceAdminTest/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth



What I dont understand is that the line that prints enumeration name = 
find the insuranceAdminTest binding, but the subsequent lookup on the
jdbcContext Context fails...




Does anyone know what is wrong?


Many thanks - Adam Lipscombe



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:
mailto:[EMAIL