geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Gbean and EJBs
Date Tue, 08 Jan 2008 18:27:05 GMT

On Jan 8, 2008, at 1:34 AM, ivanrc wrote:

>
> I doesn´t work. I can obtain EJB local interface. I think this  
> lines work as
> if I do new InitialContext() without parameters.
>
> I would like to obtain the interface as we do with EJB 3.0. I try  
> it adding
> this lines to source code...

This absolutely definitely will not work.  GBeans are lower-level  
server components that aren't really expected to use jndi (for  
instance the jndi system is set up with a few gbeans), and we  
certainly don't provide jndi-based dependency injection through  
annotations for them.  You have to look up the ejb in jndi "by  
hand".  I would recommend using "new InitialContext()" if you can get  
it to work since you can arrange for other things like datasources to  
be available there as well, whereas with the openejb jndi system I  
don't think datasources are available.

thanks
david jencks

>
> @EJB(name="TeamBeanRemote")
> TeamRemote local=null;
>
> -- and adding a ejb-ref to gbean tag as this:
>
>
> <gbean name="TestGBean" class="com.test.SSEGBean">
>   	<attribute name="port">4201</attribute>
> 	<attribute name="host">localhost</attribute>
> 	<ejb-ref>
>         <ref-name>TeamBeanRemote</ref-name>
>         <nam:pattern
> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1">
>            <nam:artifactId>test_ejb3</nam:artifactId>
>            <nam:name>test_ejb3</nam:name>
>         </nam:pattern>
>         </ejb-ref>
>   </gbean>
>
>
> .. but It doesn´t work.  Can I use EJB3.0 annotations inside Gbean?
>
>
>
> Jacek Laskowski wrote:
>>
>> On Jan 8, 2008 8:24 AM, ivanrc <iriano@indra.es> wrote:
>>
>>> How can Gbean obtain the global jndi?
>>
>> During "the simplest and easiest approaches" day everything should be
>> simplest and easiest (as well as intuitive) so your best bet would be
>> to look at gbean as any other java remote client and do the  
>> following:
>>
>>         Properties properties = new Properties();
>>         properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>> "org.apache.openejb.client.LocalInitialContextFactory");
>>
>>         Context ctx = new InitialContext(properties);
>>         MyEjbBeanIntf myEjbBean = (MyEjbBeanIntf)
>> ctx.lookup("MyEjbBeanLocal");
>>
>> As the gbean's actually part of the server environment, I'd expect  
>> you
>> can leave off the Context.INITIAL_CONTEXT_FACTORY setting and look up
>> ejbs without it.
>>
>> Jacek
>>
>> -- 
>> Jacek Laskowski
>> http://www.JacekLaskowski.pl
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Gbean-and-EJBs- 
> tp14615530s134p14685205.html
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Mime
View raw message