tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "asd" <>
Subject an question occured during using tomcat5.0
Date Tue, 03 Feb 2004 09:34:52 GMT
All friends:
    I had used DataSource accompanyed with tomcat5.I configured this Data which named "JDBC/ORADB"
via the web page "http://localhost:8080/admin",everything was completed.then ,i retrieved
this DataSource on my client which is an application.
My core code of client is here:

  java.util.Properties p = new java.util.Properties();
  p.put( Context.INITIAL_CONTEXT_FACTORY,"org.apache.naming.factory.ResourceFactory");
  //p.put( Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.fscontext.RefFSContextFactory");
  p.put( Context.PROVIDER_URL,"http://localhost:8080");
  //  System.setProperty("java.naming.factory,initial", "org.apache.catalina.users.MemoryUser");
  try {
   Context context = new javax.naming.InitialContext( p);
   Context initCtx = ( Context)context.lookup("java:comp/env");
   DataSource ds = ( DataSource) initCtx.lookup("JDBC/ORADB");
   return ds;
  } catch (NamingException e) {
   return null;

but it failed.And the all err message like this :
javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.factory.ResourceFactory.
 Root exception is java.lang.ClassCastException
 at javax.naming.spi.NamingManager.getInitialContext(
 at javax.naming.InitialContext.getDefaultInitCtx(
 at javax.naming.InitialContext.init(
 at javax.naming.InitialContext.<init>(
 at com.airversal.cer.utility.service.ServiceImp.getDataSource(
 at com.ariversal.cer.debug.DSTest.main(

i do not know what had happend.i look view some sample code on They all are
too simple.Error occur with my try.

what had happend or how did i use datasource with tomcat5,i beg someone give me some introduce
and some advise .
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message