Joe Gittings wrote:
> 
> Hi,
> 
> I just tried this. Unfortunately, I get a ClassCastException. It seems that
> instead of returning a DataSource, the initialContext.lookup() is returning
> an instance of org.objectweb.jonas.jtm.Current.
> 
> Looking in the archives, someone has reported this problem before
> ("DataSource problem", Miroslav Halas, 10th May 2000). Has a fix or
> workaround been found for it?
> 
> Joe
> 
Hi,
What is the difference between what you have done
and what it is done in the example eb?
Have a look at the $JONAS_ROOT/examples/src/eb
you will see that in AccountExplBean.java the getConnection method
is written as:

private Connection getConnection() throws EJBException, SQLException {
        if (dataSource == null) {
            // Finds DataSource from JNDI
            Context    initialContext = null;
            try {
                initialContext = new InitialContext();
                dataSource =
(DataSource)initialContext.lookup("java:comp/env/jdbc/AccountExplDs");
            } catch (Exception e) {
                System.out.println("Cannot lookup dataSource"+e);
                throw new javax.ejb.EJBException("Cannot lookup dataSource ");
            }
        }
        return dataSource.getConnection();
    }

with in the ejb-jar.xml :

<resource-ref>
        <res-ref-name>jdbc/AccountExplDs</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>

and it's running very well!
have you suceed to run eb example in youe environment?

-- 
        Philippe

Philippe Coq  Evidian   Phone: (33) 04 76 29 78 49
Bull S.A  - 1 rue de Provence - 38432 Echirolles Cedex France
Download our EJBServer at http://www.objectweb.org
----
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