The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Stateless Bean

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 10 - Last Post: May 23, 2008 7:23 AM by: Miroslav Nachev
Miroslav Nachev
How to take the same Stateful Bean from Remote RMI-IIOP and Local
Stateless Bean

Posted: May 20, 2008 2:35 PM
  Click to reply to this thread Reply

Hi,

After few tests I found that when one Stateful Bean is retrieved
(doLookup) through RMI-IIOP the instance is the same which must be. The
problem is when the same Stateful Bean is retrieved from the server side
from Stateless or Stateful bean.
My question is there any way from server side to retrieve the same
Stateful Bean as from client side (RMI-IIOP)?


Regards,
Miro.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


cf126330

Posts: 188
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Stat

Posted: May 21, 2008 7:59 AM   in response to: Miroslav Nachev
  Click to reply to this thread Reply

Not sure I understand your question, but in general, each lookup (from anywhere) returns a reference to a new stateful bean instance. All client invocation thru the same bean reference will be serviced by the same stateful bean instance, from the client's point of view.

-cheng

Miroslav Nachev
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Stat

Posted: May 21, 2008 7:59 AM   in response to: cf126330
  Click to reply to this thread Reply

Hi,

> in general, each lookup (from anywhere) returns a reference to a new stateful bean instance.
I am not agree with that. I do the simple tests and I see that all
lookups from the JWS (JNLP, RMI-IIOP) returns the same instance.
Unfortunately this is not the case when the lookups are coming from the
server. You can see:
* 1. Client -> SS1 -> SF1
* 2. Client -> SF1
* 3. Client -> SF2
* 4. Client -> SS2 -> SF2
* 5. Client -> SF1 -> SF2
* 6. Client -> SF1 -> SS1 -> SF1
* 7. Client -> SF1 -> SS1 -> SF2
* 8. Client -> SF2 -> SS2 -> SF2

localCall: test._SF1Bean_Serializable@1a0b066, id:4, test 1
localCall: test._SF1Bean_Serializable@1a0b066, id:4, test 6

remoteCall: test._SF1Bean_Serializable@5670b4, id:1, test 2
remoteCall: test._SF1Bean_Serializable@5670b4, id:1, test 5
remoteCall: test._SF1Bean_Serializable@5670b4, id:1, test 6
remoteCall: test._SF1Bean_Serializable@5670b4, id:1, test 7

remoteCall: test._SF2Bean_Serializable@a16872, id:3, test 3
remoteCall: test._SF2Bean_Serializable@a16872, id:3, test 8

localCall: test._SF2Bean_Serializable@460b07, id:9, test 4
localCall: test._SF2Bean_Serializable@460b07, id:9, test 8

localCall: test._SF2Bean_Serializable@1f440e7, id:2, test 5
localCall: test._SF2Bean_Serializable@131370f, id:6, test 7

All calls from the Clients using remoteCall returns the same instance
with Id:1 for SF1 and Id:3 for SF2.

The problem which I can't solve is that I need to store some User
Session specific data which to be common for all: Client (Swing), Server
(Stateful and Stateless beans). Can you give me some suggestion how to
solve that?
For example if insteand Swing JWS Client I am using HTTP Client I can
put that data in HTTPSession.


Regards,
Miro.


glassfish@javadesktop.org wrote:
> Not sure I understand your question, but in general, each lookup (from anywhere) returns a reference to a new stateful bean instance. All client invocation thru the same bean reference will be serviced by the same stateful bean instance, from the client's point of view.
>
> -cheng
> [Message sent by forum member 'cf126330' (cf126330)]
>
> http://forums.java.net/jive/thread.jspa?messageID=275738
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


cf126330

Posts: 188
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Stat

Posted: May 21, 2008 10:46 AM   in response to: Miroslav Nachev
  Click to reply to this thread Reply

>>"The problem which I can't solve is that I need to store some User
Session specific data which to be common for all: Client (Swing), Server
(Stateful and Stateless beans). Can you give me some suggestion how to
solve that?
For example if insteand Swing JWS Client I am using HTTP Client I can
put that data in HTTPSession."

Stateful EJB is the answer. I haven't seen what you've described before. If you think there is bug, please enter it in GlassFish Issue Track with testcase.

-cheng

Miroslav Nachev
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Stat

Posted: May 21, 2008 11:58 AM   in response to: cf126330
  Click to reply to this thread Reply

[att1.html]


ksak

Posts: 455
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Posted: May 22, 2008 2:07 PM   in response to: Miroslav Nachev
  Click to reply to this thread Reply

>> OK. The issue 5052 with test case is entered.

The code is behaving as required by the spec. It's not useful to store a stateful session bean
reference within a stateless session bean. An invocation on a stateless session bean
reference can be processed by *any* bean instance. There's no guarantee that the same stateless
session bean instance will be used for two successive invocations.

The EJB spec does not currently define a good way to share transient state between the
components of an EJB application. We're planning to add a new Singleton component in the next
version of the spec to address this shortcoming.

Miroslav Nachev
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Posted: May 22, 2008 2:13 PM   in response to: ksak
  Click to reply to this thread Reply

[att1.html]


ksak

Posts: 455
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Posted: May 22, 2008 2:46 PM   in response to: Miroslav Nachev
  Click to reply to this thread Reply

If you can go through the web tier for all EJB access you can store the shared application state
in ServletContext attributes. Otherwise, what people typically do is use mutable static state on
the bean class. It's not portable, but it's typically the case that there is only one version of the
class loaded per application.

Miroslav Nachev
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Posted: May 22, 2008 3:21 PM   in response to: ksak
  Click to reply to this thread Reply

[att1.html]


ksak

Posts: 455
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Posted: May 23, 2008 7:19 AM   in response to: Miroslav Nachev
  Click to reply to this thread Reply

A Singleton is used for shared state between multiple bean instances or bean components. A Stateful session bean is intended to model a conversation with a single client. A shopping cart is the canonical example of a stateful session bean use case. If you went into a grocery store, you wouldn't want many customers using the same shopping cart.

The shared vs. single-client distinction is fundamental to the component semantics. It wouldn't make sense to simply change the stateful session bean model to provide both kinds of behavior.

Miroslav Nachev
Re: How to take the same Stateful Bean from Remote RMI-IIOP and Local
Posted: May 23, 2008 7:23 AM   in response to: ksak
  Click to reply to this thread Reply

OK. The shopping cart is very good example for Web/HTML based application
where you have another extra HTTP layer. Try to get the same shopping cart
from some Session bean instead from HTTP layer. This is not possible.


Regards,
Miro.

On Fri, May 23, 2008 at 5:19 PM, <glassfish@javadesktop.org> wrote:

> A Singleton is used for shared state between multiple bean instances or
> bean components. A Stateful session bean is intended to model a
> conversation with a single client. A shopping cart is the canonical example
> of a stateful session bean use case. If you went into a grocery store, you
> wouldn't want many customers using the same shopping cart.
>
> The shared vs. single-client distinction is fundamental to the component
> semantics. It wouldn't make sense to simply change the stateful session
> bean model to provide both kinds of behavior.
> [Message sent by forum member 'ksak' (ksak)]
>
> http://forums.java.net/jive/thread.jspa?messageID=276312
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
[att1.html]





 XML java.net RSS