tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: OpenEJB - Datasource lookup problem
Date Fri, 16 May 2008 21:42:59 GMT

On May 16, 2008, at 12:02 PM, David Blevins wrote:

> Hi All,
>
> Just a note that the lookup style should definitely work.   
> Internally, Tomcat just looks things up from JNDI when doing  
> injection.
>
> To get the reference into java:comp/env/  you need to either use the  
> @Resource annotation or add an resource-ref in your web.xml like:
>
>      <resource-ref>
>        <res-ref-name>MySqlDS</res-ref-name>
>        <res-type>javax.sql.DataSource</res-type>
>        <res-auth>Container</res-auth>
>      </resource-ref>

I took a quick stab at some docs that compare annotations vs xml:

http://cwiki.apache.org/OPENEJBx30/ejb-local-ref.html
http://cwiki.apache.org/OPENEJBx30/ejb-ref.html
http://cwiki.apache.org/OPENEJBx30/resource-ref-for-datasource.html

Will get something for ConnectionFactory, EntityManager, etc. up there  
as well.

-David

>
> On May 16, 2008, at 10:17 AM, ManojS wrote:
>
>>
>> BraamB,
>>
>> I could see your message today only, since I was out of this topic  
>> with some
>> other tasks.
>>
>> I could not solve that datasource lookup problem the way I wished  
>> to solve.
>> I mean, in my source code there were many places where we used to  
>> lookup
>> datasouces simply by the following two lines of code,
>>
>> Context ctx = new InitialContext();
>> Datasource ds = (DataSource) ctx.lookup ("java:comp/env/MySqlDS" );
>>
>> All these places where throwing the "NameNotFoundException" when we  
>> migrate
>> into OpenEJB (embedded openEJB with Tomcat 6.0.16). I wanted to  
>> solve the
>> issue without touching those source codes. But finally we solved  
>> the problem
>> by the way David suggested. Using resource injection with  
>> annotation. For
>> that, those many places we had to change the source code.
>>
>> Manoj.
>>
>>
>> BraamB wrote:
>>>
>>> Hallo,
>>>
>>> Were you able to fix this problem? I am using the embedded openEJB  
>>> with
>>> Tomcat 6 and have the exact same problem. I keep getting
>>> NameNotFoundException. Could you please help?
>>>
>>>
>>
>> -- 
>> View this message in context: http://www.nabble.com/OpenEJB---Datasource-lookup-problem-tp14645858p17279958.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>
>


Mime
View raw message