Greetings.

I'm having problems pulling a Referenceable (specifically, a DataSource)
from JNDI. 

The code is pretty straight-forward:

            System.out.println("Getting a context...");
            InitialContext context = new InitialContext();
 
            System.out.println("Getting a DataSource...");
            Object obj = context.lookup("jdbc_1");
            System.out.println("Got a " + obj.getClass().getName());
 
            System.out.println("Narrowing...");
            DataSource ds =
                (DataSource)
                    PortableRemoteObject.narrow(
                        obj,
                        DataSource.class);
 
            System.out.println("Getting a connection...");
            con = ds.getConnection();
                                                     
It looks like the lookup is pulling a javax.naming.Reference out of JNDI
instead of it being dereferenced back to a DataSource.  The output is as
follows:                            

Getting a context...
Getting a DataSource...
Got a javax.naming.Reference
Narrowing...
java.lang.ClassCastException
        at
com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemo
teObject.java:296)
        at
javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
        at DataSourceTest.main(DataSourceTest.java:23)


Has anybody else come upon this and solved the problem? I'm thinking it's a
bug, possibly in org.objectweb.jonas.naming.CompNamingContext(.lookup())?
Looks like it's handling a LinkRef, but not the parent class Reference... 

Thanks much in advance,

Thomas.
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to