You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by TomMax <tr...@poczta.onet.pl> on 2009/10/13 15:01:33 UTC
[T4] Two users see the same data - problem with ASO objects
Hi all,
I'm working in a developers team with Tapestry applications (version 4.0.2)
for more than 2 years. Our Tapestry applications works on various
Application Servers (JBoss, SAP Netweaver), and usually we were able in our
team to resolve all problems, recently however, we spotted a problem with
Application State Object, which is responsible for user session data and we
can't find the bug.
The problem is that two users see sometimes the same data on a page. In our
scenario User1 and User2 have their own userSession objects (they are ASO
object with session scope), these objects keep all their data, and these
objects are injected to every page in .page file:
<inject property="userSession" object="userSession" type="state" />
Every user has own userSession object, so every user should see only his own
data on a page, but sometimes (quite rarely), we got the situation, that
User2 sees the data from User1 userSession object when he get the page,
where User1 was earlier.
So far I know, in case of ASO objects, the references in a page to these
objects, should be set to null on pageDetach action. So each time when the
user is receiving the page from PagePool (or newly created page), he should
obtain also fresh ASO object from ApplicationStateManager.
We have got currently this problem not so often (usually it is one or two
times in a two week period, in case when the application is used by 3-4
persons 8 hours per day), and when the problem happens, usually all working
users are receiving wrong data (they see the data from other users).
I hope someone will be able to help me.
Thanks
Tomek
--
View this message in context: http://www.nabble.com/-T4--Two-users-see-the-same-data---problem-with-ASO-objects-tp25872478p25872478.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [T4] Two users see the same data - problem with ASO objects
Posted by Olle Hallin <ol...@hit.se>.
Well, google for "singletons considered harmful" and reserve a couple of
hours for reading...
Here's one that explains it pretty well:
http://tech.puredanger.com/2007/07/03/pattern-hate-singleton
Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
2009/10/13 Argo Vilberg <wi...@gmail.com>
> anti-pattern?
>
> why it makes testing much harder?
>
> I use singleton for my own connection pooling and cache and cluster system.
> All works very fine!
>
> 2009/10/13 Olle Hallin <ol...@hit.se>
>
> > Singletons is an anti-pattern that the Java community abandoned years
> ago!
> > The main reason is that it makes testing much harder.
> >
> > Besides, your example is wrong. The constructor must be private, or else
> > the
> > singleton is broken.
> >
> > Olle Hallin
> > Senior Java Developer and Architect
> > olle.hallin@crisp.se
> > www.crisp.se
> >
> >
> >
> >
> > 2009/10/13 Argo Vilberg <wi...@gmail.com>
> >
> > > very simple solution is creata Singleton java class.
> > >
> > >
> > > public class MallBean{
> > > public final static MallBean INSTANCE = new MallBean();
> > >
> > > public MallBean() {
> > > }
> > >
> > > ....
> > >
> > > }
> > >
> > >
> > > And access
> > >
> > > MallBean.INSTANCE.getSomething.
> > >
> > >
> > > And if you first time calling this, class is created and only ONE this
> > type
> > > of class can be created.
> > > And this class is accessible everyone.
> > >
> > >
> > > Enjoy!
> > >
> > > Argo
> > >
> > >
> > > 2009/10/13 TomMax <tr...@poczta.onet.pl>
> > >
> > > >
> > > > Hi all,
> > > >
> > > > I'm working in a developers team with Tapestry applications (version
> > > 4.0.2)
> > > > for more than 2 years. Our Tapestry applications works on various
> > > > Application Servers (JBoss, SAP Netweaver), and usually we were able
> in
> > > our
> > > > team to resolve all problems, recently however, we spotted a problem
> > with
> > > > Application State Object, which is responsible for user session data
> > and
> > > we
> > > > can't find the bug.
> > > >
> > > > The problem is that two users see sometimes the same data on a page.
> In
> > > our
> > > > scenario User1 and User2 have their own userSession objects (they are
> > ASO
> > > > object with session scope), these objects keep all their data, and
> > these
> > > > objects are injected to every page in .page file:
> > > >
> > > > <inject property="userSession" object="userSession" type="state" />
> > > >
> > > > Every user has own userSession object, so every user should see only
> > his
> > > > own
> > > > data on a page, but sometimes (quite rarely), we got the situation,
> > that
> > > > User2 sees the data from User1 userSession object when he get the
> page,
> > > > where User1 was earlier.
> > > > So far I know, in case of ASO objects, the references in a page to
> > these
> > > > objects, should be set to null on pageDetach action. So each time
> when
> > > the
> > > > user is receiving the page from PagePool (or newly created page), he
> > > should
> > > > obtain also fresh ASO object from ApplicationStateManager.
> > > > We have got currently this problem not so often (usually it is one or
> > two
> > > > times in a two week period, in case when the application is used by
> 3-4
> > > > persons 8 hours per day), and when the problem happens, usually all
> > > working
> > > > users are receiving wrong data (they see the data from other users).
> > > >
> > > > I hope someone will be able to help me.
> > > >
> > > > Thanks
> > > > Tomek
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://www.nabble.com/-T4--Two-users-see-the-same-data---problem-with-ASO-objects-tp25872478p25872478.html
> > > > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
>
Re: [T4] Two users see the same data - problem with ASO objects
Posted by Argo Vilberg <wi...@gmail.com>.
anti-pattern?
why it makes testing much harder?
I use singleton for my own connection pooling and cache and cluster system.
All works very fine!
2009/10/13 Olle Hallin <ol...@hit.se>
> Singletons is an anti-pattern that the Java community abandoned years ago!
> The main reason is that it makes testing much harder.
>
> Besides, your example is wrong. The constructor must be private, or else
> the
> singleton is broken.
>
> Olle Hallin
> Senior Java Developer and Architect
> olle.hallin@crisp.se
> www.crisp.se
>
>
>
>
> 2009/10/13 Argo Vilberg <wi...@gmail.com>
>
> > very simple solution is creata Singleton java class.
> >
> >
> > public class MallBean{
> > public final static MallBean INSTANCE = new MallBean();
> >
> > public MallBean() {
> > }
> >
> > ....
> >
> > }
> >
> >
> > And access
> >
> > MallBean.INSTANCE.getSomething.
> >
> >
> > And if you first time calling this, class is created and only ONE this
> type
> > of class can be created.
> > And this class is accessible everyone.
> >
> >
> > Enjoy!
> >
> > Argo
> >
> >
> > 2009/10/13 TomMax <tr...@poczta.onet.pl>
> >
> > >
> > > Hi all,
> > >
> > > I'm working in a developers team with Tapestry applications (version
> > 4.0.2)
> > > for more than 2 years. Our Tapestry applications works on various
> > > Application Servers (JBoss, SAP Netweaver), and usually we were able in
> > our
> > > team to resolve all problems, recently however, we spotted a problem
> with
> > > Application State Object, which is responsible for user session data
> and
> > we
> > > can't find the bug.
> > >
> > > The problem is that two users see sometimes the same data on a page. In
> > our
> > > scenario User1 and User2 have their own userSession objects (they are
> ASO
> > > object with session scope), these objects keep all their data, and
> these
> > > objects are injected to every page in .page file:
> > >
> > > <inject property="userSession" object="userSession" type="state" />
> > >
> > > Every user has own userSession object, so every user should see only
> his
> > > own
> > > data on a page, but sometimes (quite rarely), we got the situation,
> that
> > > User2 sees the data from User1 userSession object when he get the page,
> > > where User1 was earlier.
> > > So far I know, in case of ASO objects, the references in a page to
> these
> > > objects, should be set to null on pageDetach action. So each time when
> > the
> > > user is receiving the page from PagePool (or newly created page), he
> > should
> > > obtain also fresh ASO object from ApplicationStateManager.
> > > We have got currently this problem not so often (usually it is one or
> two
> > > times in a two week period, in case when the application is used by 3-4
> > > persons 8 hours per day), and when the problem happens, usually all
> > working
> > > users are receiving wrong data (they see the data from other users).
> > >
> > > I hope someone will be able to help me.
> > >
> > > Thanks
> > > Tomek
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://www.nabble.com/-T4--Two-users-see-the-same-data---problem-with-ASO-objects-tp25872478p25872478.html
> > > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
Re: [T4] Two users see the same data - problem with ASO objects
Posted by Olle Hallin <ol...@hit.se>.
Singletons is an anti-pattern that the Java community abandoned years ago!
The main reason is that it makes testing much harder.
Besides, your example is wrong. The constructor must be private, or else the
singleton is broken.
Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
2009/10/13 Argo Vilberg <wi...@gmail.com>
> very simple solution is creata Singleton java class.
>
>
> public class MallBean{
> public final static MallBean INSTANCE = new MallBean();
>
> public MallBean() {
> }
>
> ....
>
> }
>
>
> And access
>
> MallBean.INSTANCE.getSomething.
>
>
> And if you first time calling this, class is created and only ONE this type
> of class can be created.
> And this class is accessible everyone.
>
>
> Enjoy!
>
> Argo
>
>
> 2009/10/13 TomMax <tr...@poczta.onet.pl>
>
> >
> > Hi all,
> >
> > I'm working in a developers team with Tapestry applications (version
> 4.0.2)
> > for more than 2 years. Our Tapestry applications works on various
> > Application Servers (JBoss, SAP Netweaver), and usually we were able in
> our
> > team to resolve all problems, recently however, we spotted a problem with
> > Application State Object, which is responsible for user session data and
> we
> > can't find the bug.
> >
> > The problem is that two users see sometimes the same data on a page. In
> our
> > scenario User1 and User2 have their own userSession objects (they are ASO
> > object with session scope), these objects keep all their data, and these
> > objects are injected to every page in .page file:
> >
> > <inject property="userSession" object="userSession" type="state" />
> >
> > Every user has own userSession object, so every user should see only his
> > own
> > data on a page, but sometimes (quite rarely), we got the situation, that
> > User2 sees the data from User1 userSession object when he get the page,
> > where User1 was earlier.
> > So far I know, in case of ASO objects, the references in a page to these
> > objects, should be set to null on pageDetach action. So each time when
> the
> > user is receiving the page from PagePool (or newly created page), he
> should
> > obtain also fresh ASO object from ApplicationStateManager.
> > We have got currently this problem not so often (usually it is one or two
> > times in a two week period, in case when the application is used by 3-4
> > persons 8 hours per day), and when the problem happens, usually all
> working
> > users are receiving wrong data (they see the data from other users).
> >
> > I hope someone will be able to help me.
> >
> > Thanks
> > Tomek
> >
> >
> > --
> > View this message in context:
> >
> http://www.nabble.com/-T4--Two-users-see-the-same-data---problem-with-ASO-objects-tp25872478p25872478.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
Re: [T4] Two users see the same data - problem with ASO objects
Posted by Argo Vilberg <wi...@gmail.com>.
very simple solution is creata Singleton java class.
public class MallBean{
public final static MallBean INSTANCE = new MallBean();
public MallBean() {
}
....
}
And access
MallBean.INSTANCE.getSomething.
And if you first time calling this, class is created and only ONE this type
of class can be created.
And this class is accessible everyone.
Enjoy!
Argo
2009/10/13 TomMax <tr...@poczta.onet.pl>
>
> Hi all,
>
> I'm working in a developers team with Tapestry applications (version 4.0.2)
> for more than 2 years. Our Tapestry applications works on various
> Application Servers (JBoss, SAP Netweaver), and usually we were able in our
> team to resolve all problems, recently however, we spotted a problem with
> Application State Object, which is responsible for user session data and we
> can't find the bug.
>
> The problem is that two users see sometimes the same data on a page. In our
> scenario User1 and User2 have their own userSession objects (they are ASO
> object with session scope), these objects keep all their data, and these
> objects are injected to every page in .page file:
>
> <inject property="userSession" object="userSession" type="state" />
>
> Every user has own userSession object, so every user should see only his
> own
> data on a page, but sometimes (quite rarely), we got the situation, that
> User2 sees the data from User1 userSession object when he get the page,
> where User1 was earlier.
> So far I know, in case of ASO objects, the references in a page to these
> objects, should be set to null on pageDetach action. So each time when the
> user is receiving the page from PagePool (or newly created page), he should
> obtain also fresh ASO object from ApplicationStateManager.
> We have got currently this problem not so often (usually it is one or two
> times in a two week period, in case when the application is used by 3-4
> persons 8 hours per day), and when the problem happens, usually all working
> users are receiving wrong data (they see the data from other users).
>
> I hope someone will be able to help me.
>
> Thanks
> Tomek
>
>
> --
> View this message in context:
> http://www.nabble.com/-T4--Two-users-see-the-same-data---problem-with-ASO-objects-tp25872478p25872478.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: [T4] Two users see the same data - problem with ASO objects
Posted by Olle Hallin <ol...@hit.se>.
Another thing to look for are object references inside the ASO.
Perhaps they point to the same mutable object?
Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
2009/10/13 Martin Strand <do...@gmail.com>
> Hmm, it sounds unlikely that different sessions would get mixed up like
> that.
> Perhaps the problem is with some other variable that happens to be visible
> to several users?
>
> I haven't done Tap4 in a while, but maybe you could look for:
> - any field in a page class, they should probably all be abstract getters.
> You need to reset any such fields manually before rendering the page.
> - any non-final field in a service, they should probably all be final and
> initialized in the constructor
> Hivemind services are singletons by default so if you put any stateful
> data there it will be visible to all users
>
>
> On Tue, 13 Oct 2009 15:01:33 +0200, TomMax <tr...@poczta.onet.pl> wrote:
>
> Hi all,
>>
>> I'm working in a developers team with Tapestry applications (version
>> 4.0.2)
>> for more than 2 years. Our Tapestry applications works on various
>> Application Servers (JBoss, SAP Netweaver), and usually we were able in
>> our
>> team to resolve all problems, recently however, we spotted a problem with
>> Application State Object, which is responsible for user session data and
>> we
>> can't find the bug.
>>
>> The problem is that two users see sometimes the same data on a page. In
>> our
>> scenario User1 and User2 have their own userSession objects (they are ASO
>> object with session scope), these objects keep all their data, and these
>> objects are injected to every page in .page file:
>>
>> <inject property="userSession" object="userSession" type="state" />
>>
>> Every user has own userSession object, so every user should see only his
>> own
>> data on a page, but sometimes (quite rarely), we got the situation, that
>> User2 sees the data from User1 userSession object when he get the page,
>> where User1 was earlier.
>> So far I know, in case of ASO objects, the references in a page to these
>> objects, should be set to null on pageDetach action. So each time when the
>> user is receiving the page from PagePool (or newly created page), he
>> should
>> obtain also fresh ASO object from ApplicationStateManager.
>> We have got currently this problem not so often (usually it is one or two
>> times in a two week period, in case when the application is used by 3-4
>> persons 8 hours per day), and when the problem happens, usually all
>> working
>> users are receiving wrong data (they see the data from other users).
>>
>> I hope someone will be able to help me.
>>
>> Thanks
>> Tomek
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: [T4] Two users see the same data - problem with ASO objects
Posted by Martin Strand <do...@gmail.com>.
Hmm, it sounds unlikely that different sessions would get mixed up like that.
Perhaps the problem is with some other variable that happens to be visible to several users?
I haven't done Tap4 in a while, but maybe you could look for:
- any field in a page class, they should probably all be abstract getters.
You need to reset any such fields manually before rendering the page.
- any non-final field in a service, they should probably all be final and initialized in the constructor
Hivemind services are singletons by default so if you put any stateful data there it will be visible to all users
On Tue, 13 Oct 2009 15:01:33 +0200, TomMax <tr...@poczta.onet.pl> wrote:
> Hi all,
>
> I'm working in a developers team with Tapestry applications (version 4.0.2)
> for more than 2 years. Our Tapestry applications works on various
> Application Servers (JBoss, SAP Netweaver), and usually we were able in our
> team to resolve all problems, recently however, we spotted a problem with
> Application State Object, which is responsible for user session data and we
> can't find the bug.
>
> The problem is that two users see sometimes the same data on a page. In our
> scenario User1 and User2 have their own userSession objects (they are ASO
> object with session scope), these objects keep all their data, and these
> objects are injected to every page in .page file:
>
> <inject property="userSession" object="userSession" type="state" />
>
> Every user has own userSession object, so every user should see only his own
> data on a page, but sometimes (quite rarely), we got the situation, that
> User2 sees the data from User1 userSession object when he get the page,
> where User1 was earlier.
> So far I know, in case of ASO objects, the references in a page to these
> objects, should be set to null on pageDetach action. So each time when the
> user is receiving the page from PagePool (or newly created page), he should
> obtain also fresh ASO object from ApplicationStateManager.
> We have got currently this problem not so often (usually it is one or two
> times in a two week period, in case when the application is used by 3-4
> persons 8 hours per day), and when the problem happens, usually all working
> users are receiving wrong data (they see the data from other users).
>
> I hope someone will be able to help me.
>
> Thanks
> Tomek
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org