tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ManojS <manoj_...@yahoo.co.in>
Subject Re: OpenEJB - Datasource lookup problem
Date Sun, 06 Jan 2008 17:29:42 GMT

Thank you very much Mohammad and Jacek for your quick replies.

Yes, I missed to set the JNDI context factory setting at first. Now the API
has changed as follows. 

public Connection getConnection () throws Exception {
	Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
	Context ctx = new InitialContext(properties);
	Datasource ds = (Datasource) ctx.lookup( "MyDatasource" );
	return (ds!=null?ds.getConnection():null);
}

I have implemented this method in a session bean only. Also, for your
information, I have added the datasource as resource referense in my
"ejb-jar.xml" and "openejb-jar.xml" files for the session bean as follows. 

<resource-ref>
   <res-ref-name>MyDatasource</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
</resource-ref>

Still the problem exist.

Now, as you all suggested, I will use the latest openejb 3.0. Let me
configure it first, and then in any case of issues I will come back to you
for help.

Thank you very much for your help.

Manoj.


Jacek Laskowski wrote:
> 
> On Jan 6, 2008 10:51 AM, ManojS <manoj_mrs@yahoo.co.in> wrote:
> 
>> The openejb version I am using is 1.0, because the EJB version I was
>> using
>> is 2.0.
> 
> OpenEJB 3.0 (and any EJB3-compliant container) is fully
> backward-compatible with the previous ejb specs so using ejb 2.0
> doesn't necessarily mandate previous openejb releases. Having said
> this, I'd stronly recommend using OpenEJB 3.0 as the ejb container of
> your choice.
> 
> Once you're at openejb3 level look it up via
> java:openejb/Resource/MyDatasource (Connector element has recently
> been deprecated).
> 
> Download OpenEJB 3.0 from
> http://people.apache.org/~jlaskowski/openejb-3.0.0-SNAPSHOT-bin.tar.gz.
> It's a build from today's sources.
> 
> Jacek
> 
> -- 
> Jacek Laskowski
> http://www.JacekLaskowski.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p14651115.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message