Re: how to get reference of a session bean in Action

2001-04-06 Thread Menno M Jansz

Ah in the examples I of course meant 

eg request.getSession().getAttribute("userinfo");
and eg request.getSession().setAttribute("userinfo", userinfo); 

Sorry I need more caffeine,
or more sleep, Menno

06/04/2001 17:13:12, Menno M Jansz <[EMAIL PROTECTED]> wrote:

>To access EJBs in your Action do a GetAttribute on the HttpSession ( eg 
>request.getSession().getAttribute("userinfo"); ). 
>
>1. If the return is null then this indicates it is the first time for this 
>HttpSession, so do a lookup for the relevant ejb. When you 
>have a reference to it do a SetAttribute on the HttpSession (eg 
>request.getSession().setAttribute("servers", servers); )
>2. If the return is not null you have the reference to the ejb.
>
>Note the key here is that every client/user has has a unique HttpSession associated 
>with it, via a unique session id. I think 
>that's what you are getting confused about. So you can use to this HttpSession to 
>store information for this user  which you 
can 
>access across more than one page request.
>
>Hope that helps,
>
>Menno
>
>
>05/04/2001 13:26:03, "G.L. Grobe" <[EMAIL PROTECTED]> wrote:
>
>
>>If the life-span of an Action is only when that Action is being exec'd, and
>>I've created my session bean in this Action, and since this Action's
>>ActionForm class spans multiple pages, how do I grab the reference to that
>>session bean the next time that Action is exec'd? It seems a little odd to
>>have to give unique names to a setAttribute method (as any number of users
>>could jump on) and was wondering how else this might be done.
>>
>>Any help much appreciated.
>>
>
>
>






Re: how to get reference of a session bean in Action

2001-04-06 Thread Menno M Jansz


To access EJBs in your Action do a GetAttribute on the HttpSession ( eg 
request.getSession().getAttribute("userinfo"); ). 

1. If the return is null then this indicates it is the first time for this 
HttpSession, so do a lookup for the relevant ejb. When you 
have a reference to it do a SetAttribute on the HttpSession (eg 
request.getSession().setAttribute("servers", servers); )
2. If the return is not null you have the reference to the ejb.

Note the key here is that every client/user has has a unique HttpSession associated 
with it, via a unique session id. I think 
that's what you are getting confused about. So you can use to this HttpSession to 
store information for this user  which you can 
access across more than one page request.

Hope that helps,

Menno


05/04/2001 13:26:03, "G.L. Grobe" <[EMAIL PROTECTED]> wrote:


>If the life-span of an Action is only when that Action is being exec'd, and
>I've created my session bean in this Action, and since this Action's
>ActionForm class spans multiple pages, how do I grab the reference to that
>session bean the next time that Action is exec'd? It seems a little odd to
>have to give unique names to a setAttribute method (as any number of users
>could jump on) and was wondering how else this might be done.
>
>Any help much appreciated.
>






how to get reference of a session bean in Action

2001-04-05 Thread G.L. Grobe

I'm running this problem through again as I'm having a hard time figuring
out how to use the setAttribute methods to keep track of a stateful session
beans reference from within a struts Action class.

If the life-span of an Action is only when that Action is being exec'd, and
I've created my session bean in this Action, and since this Action's
ActionForm class spans multiple pages, how do I grab the reference to that
session bean the next time that Action is exec'd? It seems a little odd to
have to give unique names to a setAttribute method (as any number of users
could jump on) and was wondering how else this might be done.

Any help much appreciated.




Re: session bean in action

2001-03-31 Thread Dan Miser

Are any other EJBs working in Orion using that code? I don't use it, so I
can't say for sure, but this part looks suspect. Try importing
javax.rmi.PortableRemoteObject and using this instead:

  Object ref = ctx.lookup("ConfigBuildBean");
  ConfigBuildHome home = (ConfigBuildHome)
PortableRemoteObject.narrow(ref, ConfigBuildHome.class);
--
Dan Miser
http://www.distribucon.com

- Original Message -
From: "G.L. Grobe" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 29, 2001 9:02 PM
Subject: session bean in action


> I'm getting the error at the bottom and would like to know if there's
> anything special I need to do inside an Action. Server type is Orion
1.4.5.
>

>  Context ctx = new InitialContext(env);
>
>  ConfigBuildHome home = (ConfigBuildHome)
> ctx.lookup("ConfigBuildBean");





session bean in action

2001-03-29 Thread G.L. Grobe

I'm getting the error at the bottom and would like to know if there's
anything special I need to do inside an Action. Server type is Orion 1.4.5.

ConfigBuildBean - Session Bean
ConfigBuildHome - EJBHome
ConfigBuild - EJBObject

-- ejb-jar.xml 

  
 Used in the configuration of new builds.
 Build Configuration Session Bean
 com.neuroquest.cais.ejb.config.ConfigBuildBean

com.neuroquest.cais.ejb.config.ConfigBuildBean
 com.neuroquest.cais.ejb.config.ConfigBuildHome
 com.neuroquest.cais.ejb.config.ConfigBuild
 Stateless
 Container
  

 Session Bean Implementations --

public class NewAction extends Action
{
   public ActionForward perform(ActionMapping mapping, ActionForm form,
 HttpServletRequest request, HttpServletResponse response) {

  // turn form instance into custom form bean.
  NewForm newForm = (NewForm) form;
  //String viewName = newForm.getView();

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

 ConfigBuildHome home = (ConfigBuildHome)
ctx.lookup("ConfigBuildBean");

 ConfigBuild cfgBuild = home.create();
 cfgBuild.saveConfig();
  }
  catch (Exception e) {
 log(e);
 e.printStackTrace();
  }
  ...

- The Error --

cassia(root):/u/public/orion# java -jar orion.jar
Auto-unpacking /u/build/release/cais.ear... done.
Auto-deploying cais-ejb.jar (ejb-jar.xml had been touched since the previous
deployment)... done.
Orion/1.4.5 initialized
javax.naming.NameNotFoundException: ConfigBuildHome 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)
at com.neuroquest.cais.actions.NewAction.perform(NewAction.java,
Compiled Code)
at
org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.ja
va, Compiled Code)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java, Compiled
Code)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java,
Compiled Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled
Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled
Code)
at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled
Code)
at com.evermind.server.http.d3.sw(JAX, Compiled Code)
at com.evermind.server.http.d3.su(JAX, Compiled Code)
at com.evermind.server.http.ef.s1(JAX, Compiled Code)
at com.evermind.server.http.ef.do(JAX, Compiled Code)
at com.evermind.util.f.run(JAX, Compiled Code)





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