struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ana Narvaez Vila" <ana.narv...@sema.es>
Subject Re: init'ing a session bean in Action
Date Thu, 29 Mar 2001 08:23:03 GMT
what you have to lookup is the jndi name. I am using Weblogic and I have
a weblogic-ejb-jar.xml where you say the name you want to put to EJB in
jndi directory.

 <jndi-name>namexxx</jndi-name>


     ConfigHome home = (ConfigHome) ctx.lookup("namexxx");


Bye



> "G.L. Grobe" wrote:
> 
> Probably not the right group and I'm new to ejb's and am having a
> problem getting a sesson bean going from within an Action class (a
> class from the apache struts framework which probably doesn't make a
> difference what the class is). Is this on the right track to doing
> this correctly, though I get the following error.
> 
> javax.naming.NameNotFoundException: ConfigHome not found
>         at com.evermind.server.rmi.RMIContext.lookup(JAX, Compiled
> Code)
>         at com.evermind.server.hm.f4(JAX, Compiled Code)
>         at com.evermind.server.hm.lookup(JAX, Compiled Code)
>         at javax.naming.InitialContext.lookup(InitialContext.java,
> Compiled Code)
> My Sesson bean is made up of the following:
> ConfigHome - home interface
> ConfigBean - session bean
> Config - ejbobject interface
> 
> My ejb-jar.xml file looks like this.
> 
>    <session>
>          <display-name>Configuration Session Bean</display-name>
>          <ejb-name>com.neuroquest.cais.ejb.config.Config</ejb-name>
>          <home>com.neuroquest.cais.ejb.config.ConfigHome</home>
>          <remote>com.neuroquest.cais.ejb.config.Config</remote>
> 
> <ejb-class>com.neuroquest.cais.ejb.config.ConfigBean</ejb-class>
>          <session-type>Stateless</session-type>
>       </session>
> 
> 
> Any help much appreciated.
> 
> ----------------------------------
>  public ActionForward perform(ActionMapping mapping, ActionForm form,
>          HttpServletRequest request, HttpServletResponse response) {
> 
>       String initCtxFactory =
> getInitParameter(Context.INITIAL_CONTEXT_FACTORY);
>       String providerURL = getInitParameter(Context.PROVIDER_URL);
> 
>       try {
> 
>          Properties env = System.getProperties();
>          env.put(Context.INITIAL_CONTEXT_FACTORY, initCtxFactory);
>          env.put(Context.PROVIDER_URL, providerURL);
> 
>          Context ctx = new InitialContext(env);
> 
>          ConfigHome home = (ConfigHome) ctx.lookup("ConfigHome");
> 
>          ConfigBean cfgBean = home.create();
>          cfgBean.doMyMethod();
>       }
>       catch (Exception e) {
>          log(e);
>          e.printStackTrace();
>       }
> 
>
------------------------------------------------------------------
This email is confidential and intended solely for the use of the individual to whom it is
addressed. Any views or opinions presented are solely those of the author and do not necessarily
represent those of Sema Group. 
If you are not the intended recipient, be advised that you have received this email in error
and that any use, dissemination, forwarding, printing, or copying of this email is strictly
prohibited.
------------------------------------------------------------------


Mime
View raw message