  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Struts - A MVC web framework | | Tomcat - JSP/Servlet container | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | | JSP - A mailing list about Java Server Pages specification and reference | |
Struts & Hibernate
|
|
|
  | | | an question occured during using tomcat5.0 | an question occured during using tomcat5.0 2004-02-03 - By Bodycombe, Andrew
Back 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@(protected)] Sent: 03 February 2004 09:41 To: tomcat-user@(protected) 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 .html>java.util.Properties java.util.Properties .java.html> ' border=0> p = new java.util.Properties .html>java.util.Properties java.util.Properties .java.html> ' border=0>(); 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 (NamingManager.java:649) at javax.naming.InitialContext (InitialContext.java:243) at javax.naming.InitialContext (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@(protected) For additional commands, e-mail: tomcat-user-help@(protected)
|
|
 |