Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 51438 invoked by uid 500); 20 Aug 2001 22:40:04 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: tomcat-user@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 51431 invoked from network); 20 Aug 2001 22:40:03 -0000 Received: from ns.sentex.ca (HELO granite.sentex.ca) (199.212.134.1) by h31.sny.collab.net with SMTP; 20 Aug 2001 22:40:03 -0000 Received: from someone (p108b.xDSL-1mm.sentex.ca [64.7.134.237]) by granite.sentex.ca (8.11.4/8.11.4) with SMTP id f7KMdfK90988 for ; Mon, 20 Aug 2001 18:39:41 -0400 (EDT) (envelope-from rslifka@home.com) From: "Rob S." To: Subject: RE: tomcat 4 datasource casting Date: Mon, 20 Aug 2001 18:42:05 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Importance: Normal In-Reply-To: X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N ...and the second example for my "class-not-found" document presents itself =) Thanks guys! - r > -----Original Message----- > From: craigmcc@sfu.ca [mailto:craigmcc@sfu.ca]On Behalf Of Craig R. > McClanahan > Sent: Monday, August 20, 2001 6:16 PM > To: tomcat-user@jakarta.apache.org > Subject: Re: tomcat 4 datasource casting > > > Where do you have the jdbc2_0-stdext.jar file? I'm betting that it needs > to be in $CATALINA_HOME/common/lib only for this to work -- because JAR > files here are on the class loading path for both Catalina internal > classes and web application classes. > > Craig > > > On Mon, 20 Aug 2001 VASQUEZ_JASON@LILLY.COM wrote: > > > Hello all, > > > > I read the great message Craig McClanahan posted in the archives (from > > Aug 4) about how to setup and use a tomcat 4 datasource. All > has seemed > > to go pretty well, but I'm having a funny problem, which I'm > not sure is a > > Tyrex problem, a Tomcat 4 problem or a Java education problem > on my part > > :). (I'm using Tomcat 4 beta 7) > > > > When I try to get a DataSource from JNDI, I can retrieve a > reference just > > fine. The problem is that I am having trouble casting it to a > > javax.sql.DataSource. It returns an instance of > > tyrex.jdbc.xa.EnabledDataSource. If I try to cast to > > javax.sql.DataSource, I get a ClassCastException from the server. I > > looked up this class in the Tyrex API docs, and it does in fact > implement > > javax.sql.DataSource -- I think I should be able to cast to it > because of > > that. If I work with the tyrex implementation directly, all is > ok (i.e., > > calling tyrex.jdbc.xa.EnabledDataSource.getConnection()), but I > obviously > > won't want to care about the particular implementation in this case. > > > > If it helps, here is the code I'm trying to use: > > > > -------------------------- > > ctx = new InitialContext(); > > ds = (DataSource)ctx.lookup("java:comp/env/jdbc/lis_ds"); > > -------------------------- > > > > That failed, so I added this for debugging: > > > > -------------------------- > > Object o = ctx.lookup("java:comp/env/jdbc/lis_ds"); > > if (o == null) { > > System.out.println("looked up a null object"); > > } else { > > System.out.println("o is of type: " + o.getClass().getName()); //<-- > > prints "tyrex.jdbc.xa.EnabledDataSource" > > } > > -------------------------- > > > > The exceptions I get are like this: > > > > -------------------------- > > java.lang.ClassCastException: tyrex.jdbc.xa.EnabledDataSource > > at report.ReportPrefs.setDateDefaults(ReportPrefs.java:52) > > at report.ReportPrefs.(ReportPrefs.java:16) > > at java.lang.Class.newInstance0(Native Method) > > at java.lang.Class.newInstance(Class.java:237) > > at java.beans.Beans.instantiate(Beans.java:207) > > at java.beans.Beans.instantiate(Beans.java:51) > > ........ > > -------------------------- > > > > Any ideas? > > > > Thanks, > > Jason Vasquez > > > >