tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bodycombe, Andrew" <andrew.bodyco...@siemens.com>
Subject RE: an question occured during using tomcat5.0
Date Tue, 03 Feb 2004 12:26:29 GMT
Tomcat does not expose it's JNDI resources to the outside world. Therefore
you cannot access any Tomcat Data Sources from an application outside
tomcat.

-----Original Message-----
From: asd [mailto:liurx_cn@hotmail.com] 
Sent: 03 February 2004 09:41
To: tomcat-user@jakarta.apache.org
Subject: an question occured during using tomcat5.0


All friends:
    hello.
    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) {
   e.printStackTrace();
   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(NamingManager.java:649)
 at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
 at javax.naming.InitialContext.init(InitialContext.java:219)
 at javax.naming.InitialContext.<init>(InitialContext.java:195)
 at
com.airversal.cer.utility.service.ServiceImp.getDataSource(ServiceImp.java:4
8)
 at com.ariversal.cer.debug.DSTest.main(DSTest.java:21)

i do not know what had happend.i look view some sample code on
www.apache.org. 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 .

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message