Re: init'ing a session bean in Action

2001-03-29 Thread Ana Narvaez Vila

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.

 namexxx


 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.
> 
>
>  Configuration Session Bean
>  com.neuroquest.cais.ejb.config.Config
>  com.neuroquest.cais.ejb.config.ConfigHome
>  com.neuroquest.cais.ejb.config.Config
> 
> com.neuroquest.cais.ejb.config.ConfigBean
>  Stateless
>   
> 
> 
> 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.
--




init'ing a session bean in Action

2001-03-28 Thread G.L. Grobe



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 
interfaceConfigBean - session beanConfig - ejbobject interface
 
My ejb-jar.xml file looks like this.
 
   
 
Configuration Session 
Bean 
com.neuroquest.cais.ejb.config.Config 
com.neuroquest.cais.ejb.config.ConfigHome 
com.neuroquest.cais.ejb.config.Config 
com.neuroquest.cais.ejb.config.ConfigBean 
Stateless  

 
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();  }