Are you sure you don't have to use PortableRemoteObject.narrow() after
looking up the DataSource?

> -----Original Message-----
> From: Rodrigo B. de Oliveira [SMTP:[EMAIL PROTECTED]]
> Sent: 19 September 2000 13:02
> To:   'jBoss'
> Subject:      RE: [jBoss-User] Datasource exception
> 
> But it's not a bean. I'm having the same problem trying to acquire a
> connection inside a JSP (Tomcat running inproc to jboss).
> 
> Is it doable at all? 
> 
> Here's the code for my JSP page: 
> <%@ page import="javax.naming.*,java.sql.*,javax.sql.*" %> 
> <% 
> InitialContext context = new InitialContext(); 
> Object dsObject = context.lookup("InstantDB"); 
> %> 
> <html> 
> <body> 
> Hello, JBOSS!!<br /> 
> DataSource is <%=dsObject.toString()%>. Class is
> <%=dsObject.getClass().getName()%><br /> 
> 
> Dumping references...<br /> 
> <% 
> Reference ref = (Reference)dsObject; 
> %> 
> 
> Storing <%=ref.size()%> references of class <%=ref.getClassName()%>.<br />
> 
> 
> Narrowing... 
> <% 
> 'Exception... 
> DataSource ds =
> (DataSource)javax.rmi.PortableRemoteObject.narrow(dsObject,
> DataSource.class); 
> %> 
> 
> </table> 
> </body> 
> </html> 
> 
> Thanks, 
> Rodrigo 
> 
> -----Original Message----- 
> From: Aaron Mulder [ <mailto:[EMAIL PROTECTED]>] 
> Sent: Monday, September 18, 2000 1:09 PM 
> To: jBoss 
> Subject: Re: [jBoss-User] Datasource exception 
> 
> 
>         Use the JNDI name "java:/comp/env/Hypersonic".  Be sure to declare
> 
> the data source in your ejb-jar.xml file for that bean. 
> 
> Aaron 
> 
> On Mon, 18 Sep 2000, Sean O'Connor wrote: 
> > I am trying to write a "hello world" type client app that connects to 
> > the default Hypersonic database.  The result when I try to cast to the 
> > DataSource is the following exception.  I know it's finding 
> > "Hypersonic", if I change that, I'll get a naming exception. 
> > 
> > Exception: java.lang.ClassCastException: javax.naming.Reference 
> > 
> > Any ideas why?  Everything looks ok to me.  Here's the source. 
> > 
> > Thanks. 
> > Sean 
> > 
> > import java.sql.*; 
> > import javax.sql.*; 
> > import java.util.*; 
> > import javax.ejb.*; 
> > import javax.naming.*; 
> > 
> > public class DBBoss { 
> > 
> >       public static void main(String[] args) { 
> > 
> >               String sql = "create table test ( column1 integer )"; 
> > 
> >               try { 
> >                       Context ctx = new InitialContext(); 
> > 
> >                       DataSource ds = (DataSource)
> ctx.lookup("java:Hypersonic"); 
> >                       Connection con = ds.getConnection(); 
> > 
> >                       Statement stmt = con.createStatement(); 
> >                       stmt.execute(sql); 
> >                       stmt.close(); 
> >                       con.close(); 
> >               } catch (Exception se) { 
> >                       System.out.println("Exception: " + se); 
> >               } 
> >       } 
> > } 
> > 
> > 
> > 
> > 
> > __________________________________________________ 
> > Do You Yahoo!? 
> > Yahoo! Mail - Free email you can access from anywhere! 
> > <http://mail.yahoo.com/> 
> > 
> > 
> > -- 
> > -------------------------------------------------------------- 
> > To subscribe:        [EMAIL PROTECTED] 
> > To unsubscribe:      [EMAIL PROTECTED] 
> > Problems?:           [EMAIL PROTECTED] 
> > 
> 
> 
> 
> -- 
> -------------------------------------------------------------- 
> To subscribe:        [EMAIL PROTECTED] 
> To unsubscribe:      [EMAIL PROTECTED] 
> Problems?:           [EMAIL PROTECTED] 
> 


+----------------------------------------------------------------+
This message and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to 
whom they are addressed.  If you have received this message in 
error please delete it and any files transmitted with it, after
notifying [EMAIL PROTECTED]

Any opinions expressed in this message may be those of the author
and not necessarily those of the Company.  The Company accepts no
responsibility for the accuracy or completeness of any information
contained herein.  This message is not intended to create legal 
relations between the Company and the recipient.

Recipients should please note that messages sent via the internet
may be intercepted and that caution should therefore be exercised
before despatching to the Company any confidential or sensitive
information.
+----------------------------------------------------------------+


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to