RE: Invoking EJB from Action classes

2001-05-21 Thread Owen Taylor

I assume you are accessing the beans through JNDI.
I also assume you are using IntitialContext ctx = new InitialContext();
-to generate your initial context object.

You May create a jndi.properties file that contains the following:
java.naming.factory.initial=
java.naming.provider.url=http://www.customware.com


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Monday, May 21, 2001 12:03 PM
To: [EMAIL PROTECTED]
Subject: Invoking EJB from Action classes





Hi all,

I have developed the web front end using Struts framework. When i was trying
to
deploy the application on
Websphere 3.5.2 i am facing problems.

>From the Action class i am not able to invoke the session bean or entity
bean.
When the session
and entity beans were deployed on the websphere Access permissions were
applied
on it.  Because of these
permissions i think i am not able to invoke the beans from my Action
objects.

How can i invoke the EJB's from Action classes?

Thanks in advance.

Cheers
Rafee




**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.Kindlesystems.com
**




Re: Invoking EJB from Action classes

2001-01-16 Thread Jannik Nørgaard Steen

- Original Message -
From: "Roger Kjensrud" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 15, 2001 5:15 PM
Subject: RE: Invoking EJB from Action classes


> Jannik,
>
> thanks for your input.
>
> The concept of the EJB session manager returning references to other EJBs
is
> interesting. This EJB must be a stateful EJB with one instance per
session,
> correct? Not having the lookup and create logic in the Action class means
> that this code does not have to be duplicated in a non-HTTP environment
> where the Action classes probably don't exist. You just have to lookup the
> session manager, and it will return references for you.
>

Yes, the SessionManager is a stateful EJB.

> I don't fully understand the JNDI concept with this approach. From your
> Action class you tell the session manager to return a specific EJB
> reference, so you have to give it a JNDI name, correct? If this is true,
> where is the name stored? Hard coded? Config file?

We've implemented the home-interface lookup for the EJB SessionManager
in the user object (will probably move this to a seperate clientside session
manager class
later to keep things cleaner). When the user object is bound to the
HTTP-session
the SessionManager EJB is looked up and a remote interface is stored in the
user
object.
The SessionManager EJB can then be used to get remote interfaces references
of other EJB's.

The JNDI name of the SessionManager EJB is retrieved from a CORBA-server
that
keeps all the system specific properties, such as JNDI-name spaces. The
properties of
read by the CORBA-server is kept in a .properties file.

Hope this cleared thing up a bit..:)

/jannik

>
> Thanks,
> Roger
>
> > -Original Message-
> > From: Jannik Nørgaard Steen [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, January 13, 2001 3:09 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Invoking EJB from Action classes
> >
> >
> > Hi,
> >
> > we are storing references to our EJB in the HTTP-session context and it
> > works just fine.
> >
> > We have created an EJB that acts as a session manager. This manager can
> > supply clients with all EJB references to other EJB's one might
> > need during
> > a HTTP-session.
> >
> > On the client side we have a class (to represent a user) that
> > implements the
> > HttpBindingListener interface. When this class is bound to the
> > HTTP-session
> > a reference to the session manager is placed in the HTTP-session
> > and we are
> > ready to go.
> > Once a EJB reference (remote interface) is returned by the session
manager
> > it is stored in the HTTP-session by one of our action classes.
> > When the HTTP-session is invalidated remove() is called on all EJB
> > references stored in the
> > HTTP-session. The last to be removed is the session manager so it
> > will have
> > a chance to end transactions.
> >
> > In question of the JNDI lookup, we use a CORBA server (we call it a
> > preferences manager) to supply all clients with the JNDI name
> > space for the
> > EJB's.
> >
> >
> > Cheers,
> >
> > Jannik Nørgaard Steen
> > Software developer
> > Digital Zone International A/S
> >
> > - Original Message -
> > From: "Roger Kjensrud" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, January 12, 2001 9:50 PM
> > Subject: Invoking EJB from Action classes
> >
> >
> > > Hello,
> > >
> > > I've searched archive about calling EJBs from the Action classes and
how
> > to
> > > store the EJB reference, and there did not seem to be consensus
> > of how to
> > do
> > > this. Since the Action class needs to be coded thread-safe, and
> > you would
> > > like to keep the EJB reference, at least for stateful session EJBs, it
> > won't
> > > work to use an instance variable to store the reference.
> > >
> > > What about storing the reference in the session?
> > >
> > > So, in the perform() method of the Action class you will check to see
if
> > the
> > > session contains the reference, and if not you will call a method,
could
> > be
> > > static, that returns the ejbhome reference. This reference can be
stored
> > on
> > > the session or you can call the create() method on the ejbhome to get
a
> > > reference to the ejb and store this to the session.
> > >
> > > I would also consider creating a custom mapping where I would
> > specify the
> > > EJB JNDI lookup name in the struts-config.xml file for this particular
> > > Action class avoiding hardcoding.
> > >
> > > Feedback on this approach is appreciated,
> > >
> > > thanks,
> > > Roger Kjensrud
> > >
> > >
> >
>
>




RE: Invoking EJB from Action classes

2001-01-16 Thread Laine Donlan

>Roger Kjensrud wrote:

>> Jannik,
>>
>> thanks for your input.
>>
>> The concept of the EJB session manager returning references to other
EJBs is
>> interesting. This EJB must be a stateful EJB with one instance per
session,
>> correct? Not having the lookup and create logic in the Action class
means
>> that this code does not have to be duplicated in a non-HTTP
environment
>> where the Action classes probably don't exist. You just have to
lookup the
>> session manager, and it will return references for you.
>>
>> I don't fully understand the JNDI concept with this approach. From
your
>> Action class you tell the session manager to return a specific EJB
>> reference, so you have to give it a JNDI name, correct? If this is
true,
>> where is the name stored? Hard coded? Config file?
>>

>The web application deployment descriptor includes several elements
(such as
>) for precisely this purpose.  The details of how they are
used is
>defined in the J2EE specification, which you can grab via
><http://java.sun.com/j2ee>.

I was under the impression that the  entries were not required
elements of the spec.  And that not all servers.  Isn't support slated
for Tomcat 4.0?  Has anyone implemented it in Weblogic 5.1 sp 8.

Thanks

Laine


>>
>> Thanks,
>> Roger
>>

>Craig McClanahan


>
> > -----Original Message-----
> > From: Jannik Nørgaard Steen [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, January 13, 2001 3:09 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Invoking EJB from Action classes
> >
> >
> > Hi,
> >
> > we are storing references to our EJB in the HTTP-session context and
it
> > works just fine.
> >
> > We have created an EJB that acts as a session manager. This manager
can
> > supply clients with all EJB references to other EJB's one might
> > need during
> > a HTTP-session.
> >
> > On the client side we have a class (to represent a user) that
> > implements the
> > HttpBindingListener interface. When this class is bound to the
> > HTTP-session
> > a reference to the session manager is placed in the HTTP-session
> > and we are
> > ready to go.
> > Once a EJB reference (remote interface) is returned by the session
manager
> > it is stored in the HTTP-session by one of our action classes.
> > When the HTTP-session is invalidated remove() is called on all EJB
> > references stored in the
> > HTTP-session. The last to be removed is the session manager so it
> > will have
> > a chance to end transactions.
> >
> > In question of the JNDI lookup, we use a CORBA server (we call it a
> > preferences manager) to supply all clients with the JNDI name
> > space for the
> > EJB's.
> >
> >
> > Cheers,
> >
> > Jannik Nørgaard Steen
> > Software developer
> > Digital Zone International A/S
> >
> > - Original Message -
> > From: "Roger Kjensrud" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, January 12, 2001 9:50 PM
> > Subject: Invoking EJB from Action classes
> >
> >
> > > Hello,
> > >
> > > I've searched archive about calling EJBs from the Action classes
and how
> > to
> > > store the EJB reference, and there did not seem to be consensus
> > of how to
> > do
> > > this. Since the Action class needs to be coded thread-safe, and
> > you would
> > > like to keep the EJB reference, at least for stateful session
EJBs, it
> > won't
> > > work to use an instance variable to store the reference.
> > >
> > > What about storing the reference in the session?
> > >
> > > So, in the perform() method of the Action class you will check to
see if
> > the
> > > session contains the reference, and if not you will call a method,
could
> > be
> > > static, that returns the ejbhome reference. This reference can be
stored
> > on
> > > the session or you can call the create() method on the ejbhome to
get a
> > > reference to the ejb and store this to the session.
> > >
> > > I would also consider creating a custom mapping where I would
> > specify the
> > > EJB JNDI lookup name in the struts-config.xml file for this
particular
> > > Action class avoiding hardcoding.
> > >
> > > Feedback on this approach is appreciated,
> > >
> > > thanks,
> > > Roger Kjensrud
> > >
> > >
> >



Re: Invoking EJB from Action classes

2001-01-15 Thread Craig R. McClanahan

Roger Kjensrud wrote:

> Jannik,
>
> thanks for your input.
>
> The concept of the EJB session manager returning references to other EJBs is
> interesting. This EJB must be a stateful EJB with one instance per session,
> correct? Not having the lookup and create logic in the Action class means
> that this code does not have to be duplicated in a non-HTTP environment
> where the Action classes probably don't exist. You just have to lookup the
> session manager, and it will return references for you.
>
> I don't fully understand the JNDI concept with this approach. From your
> Action class you tell the session manager to return a specific EJB
> reference, so you have to give it a JNDI name, correct? If this is true,
> where is the name stored? Hard coded? Config file?
>

The web application deployment descriptor includes several elements (such as
) for precisely this purpose.  The details of how they are used is
defined in the J2EE specification, which you can grab via
<http://java.sun.com/j2ee>.

>
> Thanks,
> Roger
>

Craig McClanahan


>
> > -Original Message-
> > From: Jannik Nørgaard Steen [mailto:[EMAIL PROTECTED]]
> > Sent: Saturday, January 13, 2001 3:09 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Invoking EJB from Action classes
> >
> >
> > Hi,
> >
> > we are storing references to our EJB in the HTTP-session context and it
> > works just fine.
> >
> > We have created an EJB that acts as a session manager. This manager can
> > supply clients with all EJB references to other EJB's one might
> > need during
> > a HTTP-session.
> >
> > On the client side we have a class (to represent a user) that
> > implements the
> > HttpBindingListener interface. When this class is bound to the
> > HTTP-session
> > a reference to the session manager is placed in the HTTP-session
> > and we are
> > ready to go.
> > Once a EJB reference (remote interface) is returned by the session manager
> > it is stored in the HTTP-session by one of our action classes.
> > When the HTTP-session is invalidated remove() is called on all EJB
> > references stored in the
> > HTTP-session. The last to be removed is the session manager so it
> > will have
> > a chance to end transactions.
> >
> > In question of the JNDI lookup, we use a CORBA server (we call it a
> > preferences manager) to supply all clients with the JNDI name
> > space for the
> > EJB's.
> >
> >
> > Cheers,
> >
> > Jannik Nørgaard Steen
> > Software developer
> > Digital Zone International A/S
> >
> > - Original Message -
> > From: "Roger Kjensrud" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, January 12, 2001 9:50 PM
> > Subject: Invoking EJB from Action classes
> >
> >
> > > Hello,
> > >
> > > I've searched archive about calling EJBs from the Action classes and how
> > to
> > > store the EJB reference, and there did not seem to be consensus
> > of how to
> > do
> > > this. Since the Action class needs to be coded thread-safe, and
> > you would
> > > like to keep the EJB reference, at least for stateful session EJBs, it
> > won't
> > > work to use an instance variable to store the reference.
> > >
> > > What about storing the reference in the session?
> > >
> > > So, in the perform() method of the Action class you will check to see if
> > the
> > > session contains the reference, and if not you will call a method, could
> > be
> > > static, that returns the ejbhome reference. This reference can be stored
> > on
> > > the session or you can call the create() method on the ejbhome to get a
> > > reference to the ejb and store this to the session.
> > >
> > > I would also consider creating a custom mapping where I would
> > specify the
> > > EJB JNDI lookup name in the struts-config.xml file for this particular
> > > Action class avoiding hardcoding.
> > >
> > > Feedback on this approach is appreciated,
> > >
> > > thanks,
> > > Roger Kjensrud
> > >
> > >
> >



RE: Invoking EJB from Action classes

2001-01-15 Thread Roger Kjensrud

Jannik,

thanks for your input.

The concept of the EJB session manager returning references to other EJBs is
interesting. This EJB must be a stateful EJB with one instance per session,
correct? Not having the lookup and create logic in the Action class means
that this code does not have to be duplicated in a non-HTTP environment
where the Action classes probably don't exist. You just have to lookup the
session manager, and it will return references for you.

I don't fully understand the JNDI concept with this approach. From your
Action class you tell the session manager to return a specific EJB
reference, so you have to give it a JNDI name, correct? If this is true,
where is the name stored? Hard coded? Config file?

Thanks,
Roger

> -Original Message-
> From: Jannik Nørgaard Steen [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, January 13, 2001 3:09 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Invoking EJB from Action classes
>
>
> Hi,
>
> we are storing references to our EJB in the HTTP-session context and it
> works just fine.
>
> We have created an EJB that acts as a session manager. This manager can
> supply clients with all EJB references to other EJB's one might
> need during
> a HTTP-session.
>
> On the client side we have a class (to represent a user) that
> implements the
> HttpBindingListener interface. When this class is bound to the
> HTTP-session
> a reference to the session manager is placed in the HTTP-session
> and we are
> ready to go.
> Once a EJB reference (remote interface) is returned by the session manager
> it is stored in the HTTP-session by one of our action classes.
> When the HTTP-session is invalidated remove() is called on all EJB
> references stored in the
> HTTP-session. The last to be removed is the session manager so it
> will have
> a chance to end transactions.
>
> In question of the JNDI lookup, we use a CORBA server (we call it a
> preferences manager) to supply all clients with the JNDI name
> space for the
> EJB's.
>
>
> Cheers,
>
> Jannik Nørgaard Steen
> Software developer
> Digital Zone International A/S
>
> - Original Message -
> From: "Roger Kjensrud" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, January 12, 2001 9:50 PM
> Subject: Invoking EJB from Action classes
>
>
> > Hello,
> >
> > I've searched archive about calling EJBs from the Action classes and how
> to
> > store the EJB reference, and there did not seem to be consensus
> of how to
> do
> > this. Since the Action class needs to be coded thread-safe, and
> you would
> > like to keep the EJB reference, at least for stateful session EJBs, it
> won't
> > work to use an instance variable to store the reference.
> >
> > What about storing the reference in the session?
> >
> > So, in the perform() method of the Action class you will check to see if
> the
> > session contains the reference, and if not you will call a method, could
> be
> > static, that returns the ejbhome reference. This reference can be stored
> on
> > the session or you can call the create() method on the ejbhome to get a
> > reference to the ejb and store this to the session.
> >
> > I would also consider creating a custom mapping where I would
> specify the
> > EJB JNDI lookup name in the struts-config.xml file for this particular
> > Action class avoiding hardcoding.
> >
> > Feedback on this approach is appreciated,
> >
> > thanks,
> > Roger Kjensrud
> >
> >
>




Re: Invoking EJB from Action classes

2001-01-13 Thread Jannik Nørgaard Steen

Hi,

we are storing references to our EJB in the HTTP-session context and it
works just fine.

We have created an EJB that acts as a session manager. This manager can
supply clients with all EJB references to other EJB's one might need during
a HTTP-session.

On the client side we have a class (to represent a user) that implements the
HttpBindingListener interface. When this class is bound to the HTTP-session
a reference to the session manager is placed in the HTTP-session and we are
ready to go.
Once a EJB reference (remote interface) is returned by the session manager
it is stored in the HTTP-session by one of our action classes.
When the HTTP-session is invalidated remove() is called on all EJB
references stored in the
HTTP-session. The last to be removed is the session manager so it will have
a chance to end transactions.

In question of the JNDI lookup, we use a CORBA server (we call it a
preferences manager) to supply all clients with the JNDI name space for the
EJB's.


Cheers,

Jannik Nørgaard Steen
Software developer
Digital Zone International A/S

- Original Message -
From: "Roger Kjensrud" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 12, 2001 9:50 PM
Subject: Invoking EJB from Action classes


> Hello,
>
> I've searched archive about calling EJBs from the Action classes and how
to
> store the EJB reference, and there did not seem to be consensus of how to
do
> this. Since the Action class needs to be coded thread-safe, and you would
> like to keep the EJB reference, at least for stateful session EJBs, it
won't
> work to use an instance variable to store the reference.
>
> What about storing the reference in the session?
>
> So, in the perform() method of the Action class you will check to see if
the
> session contains the reference, and if not you will call a method, could
be
> static, that returns the ejbhome reference. This reference can be stored
on
> the session or you can call the create() method on the ejbhome to get a
> reference to the ejb and store this to the session.
>
> I would also consider creating a custom mapping where I would specify the
> EJB JNDI lookup name in the struts-config.xml file for this particular
> Action class avoiding hardcoding.
>
> Feedback on this approach is appreciated,
>
> thanks,
> Roger Kjensrud
>
>