geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olivier Voutat" <olivier.vou...@gmail.com>
Subject Re: Accessing locally Container Beans
Date Mon, 03 Apr 2006 09:06:38 GMT
Thanks for it Manu, but Aaron already showed me how to do it. InitialContext
without parameters and in my ejb-jar.xml:

<session>
   <ejb-name>MySession</ejb-name>
   <home>br.cefetrn.olivier.session.MySessionHome</home>
   <remote>br.cefetrn.olivier.session.MySession</remote>
   <ejb-class>br.cefetrn.olivier.session.MySessionBean</ejb-class>
   <session-type>Stateless</session-type>
   <transaction-type>Container</transaction-type>

//Reference to Entity Bean
   <ejb-local-ref>
      <ejb-ref-name>ejb/Cliente</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>br.cefetrn.olivier.entity.ClienteLocalHome</local-home>
      <local>br.cefetrn.olivier.entity.ClienteLocal</local>
      <ejb-link>Cliente</ejb-link>
   </ejb-local-ref>

//Reference to Entity Bean
   <ejb-local-ref>
      <ejb-ref-name>ejb/Carro</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
             <local-home>br.cefetrn.olivier.entity.CarroLocalHome
</local-home>
      <local>br.cefetrn.olivier.entity.CarroLocal</local>
      <ejb-link>Carro</ejb-link>
   </ejb-local-ref>

//Reference to Entity Bean
   <ejb-local-ref>
      <ejb-ref-name>ejb/Locacao</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
             <local-home>br.cefetrn.olivier.entity.LocacaoLocalHome
</local-home>
      <local>br.cefetrn.olivier.entity.LocacaoLocal</local>
      <ejb-link>Locacao</ejb-link>
   </ejb-local-ref>
</session>

In fact, I'm using a Web application but there is no need to ref in the
web.xml cause I'm creating a Ear, and for tests purposes I was using a
simple TestClass running outside the Container to see if it was working. And
don't know why but the code you're showing to use in the openejb-jar.xml,
wasn't need to get it working.

Thanks,
Olivier Voutat

On 4/3/06, Manu George <manu.t.george@gmail.com> wrote:
>
> Hi,
>         Yes you need not have any parameters when you are creating an
> InitalContext locally in the server.
>
> Suppose you have a web app that refers an ejb
> In the web.xml you should add an ejb-ref
>
>       <ejb-ref>
>          <ejb-ref-name>ejb/Trade</ejb-ref-name>
>          <ejb-ref-type>Session</ejb-ref-type>
>          <home>org.apache.geronimo.samples.daytrader.ejb.TradeHome</home>
>          <remote>org.apache.geronimo.samples.daytrader.ejb.Trade</remote>
>          <ejb-link>TradeEJB</ejb-link>
>       </ejb-ref>
>
> In your ejb-jar.xml you will define the ejb
>
>  <enterprise-beans>
>         <session>
>             <description>Trade Session EJB manages all Trading
> services</description>
>             <display-name>TradeEJB</display-name>
>             <ejb-name>TradeEJB</ejb-name>
>             <home>org.apache.geronimo.samples.daytrader.ejb.TradeHome
> </home>
>             <remote>org.apache.geronimo.samples.daytrader.ejb.Trade
> </remote>
>             <ejb-class>org.apache.geronimo.samples.daytrader.ejb.TradeBean
> </ejb-class>
>             <session-type>Stateless</session-type>
>             <transaction-type>Container</transaction-type>
>        <session>
>  </enterprise-beans>
>
> And in your openejb-jar.xml the following
>
>             <enterprise-beans>
>                 <session>
>                     <ejb-name>TradeEJB</ejb-name>
>                     <jndi-name>ejb/TradeEJB</jndi-name>
>                 </session>
>             </enterprise-beans>
>
> You can look up the daytrader application that is distributed with
> geronimo. I took the above example from that application.
>
>
> Regards
> Manu
>
>
> On 3/31/06, Olivier Voutat <olivier.voutat@gmail.com> wrote:
> >
> > You mean like this in the ejb-jar.xml ?
> >
> >   <resource-ref>
> >     <ref-name>LookupName</ref-name>
> >     <resource-link>EntityBeanName</resource-link>
> >   </resource-ref>
> >
> > but if I do it this way, how I create the context ?
> > Like this:
> >
> > Context ctx = new InitialContext(); //without parameters ?
> >
> > Best Regards,
> > Olivier Voutat
> >
> >
> > On 3/31/06, Manu George <manu.t.george@gmail.com> wrote:
> > >
> > > Hi Olivier,
> > >                You need not pass any properties to the InitialContext
> > > for local lookups from other components running in the server. You only need
> > > to give an ejb-ref in the deployment descriptor. You can get more info on
> > > this from Aaron's book
> > >
> > > http://www.chariotsolutions.com/geronimo/geronimo-html-one-page.html
> > >
> > > There are also many examples in developerworks and confluence
> > >
> > > Regards
> > > Manu
> > >
> > >
> > > On 3/30/06, Olivier Voutat < olivier.voutat@gmail.com> wrote:
> > > >
> > > > To do the remote lookup for a bean I was setting my properties like
> > > > this :
> > > >
> > > >
> > > > ----------------------------------------------------------------------------------------------------------------------------------
> > > > prop.put("java.naming.factory.initial","
> > > > org.openejb.client.RemoteInitialContextFactory");
> > > >
> > > > prop.put("java.naming.provider.url","localhost:4201");
> > > >
> > > > prop.put("java.naming.security.principal","system");
> > > >
> > > > prop.put("java.naming.security.credentials","manager");
> > > >
> > > > ----------------------------------------------------------------------------------------------------------------------------------
> > > >
> > > > I was researching and found that local calls should use:
> > > >
> > > >
> > > > ----------------------------------------------------------------------------------------------------------------------------------
> > > > prop.put("java.naming.factory.initial","
> > > > org.openejb.client.LocalInitialContextFactory");
> > > >
> > > > ----------------------------------------------------------------------------------------------------------------------------------
> > > > but the question is (and I'm asking because I didn't had enough time
> > > > to keep testing) do I need the other properties lines ? Think not because
it
> > > > is a internal container lookup but would like to be sure.
> > > >
> > > > Best Regards,
> > > > Olivier Voutat
> > > >
> > > > --
> > > > Olivier & Cidiane Voutat
> > > > Rua Praia de Muriú, 9188
> > > > Cep 59092-390 / Natal - RN
> > > > Tel: (84) 3219-0427 Cel: (84) 9977-3917
> > > >
> > >
> > >
> >
> >
> > --
> > Olivier & Cidiane Voutat
> > Rua Praia de Muriú, 9188
> > Cep 59092-390 / Natal - RN
> > Tel: (84) 3219-0427 Cel: (84) 9977-3917
> >
>
>


--
Olivier & Cidiane Voutat
Rua Praia de Muriú, 9188
Cep 59092-390 / Natal - RN
Tel: (84) 3219-0427 Cel: (84) 9977-3917

Mime
View raw message