I have seen several references to using .recycle to ensure you do not have memory issues with an xPage, however I am not sure how and where it should be used. I have checked the mastering xpages book, and have not found any specific reference to it. I suspect that this may be more obvious to those from a java background.
Should it be used when someone logs into the application, navigates between xpages? And what is this implication of use? Will it clear current sessions, or the sessionScope variables stored by a user? Is it user specific?
A
The recycling is only required for domino java objects and is not a XPage-specific issue.
You should recycle every domino object as soon you are not need it further, that's the golden rule.
Domino Objects are f.e. NotesSession, NotesDatabase, etc. They are accessed internally as C-Objects, and that is why it is important to "destroy" them manually. If you are accessing types of these objects in your code directly, you have to recycle them by yourself. XPages-specific objects like scoped variables are plain Java code and will be killed correctly by the Garbage collector.
For more details please have a look at this technote: Why it is important to use the Recycle() method on every Java object
Related
Another programmer told me about a problem, that one user sometimes sees the data of another logged-in user. Probably they are requesting the same context at the same time. I thought, that is impossible to happen? Since Garbage Collection, Container-managed Transactions and JSessionID
Without looking at the code, it is hard to guess. But maybe you have hint.
He is using this structure:
JavaEE 6 coded Web Application, using EJB and Web Container seperatly on a Glassfish v3
JSF + PrimeFaces Framework
Thanks in advance
The good news is that the EJB architecture is absolutely capable of isolating data, so this will be a bug in your code.
One thing to look for is the kind of beans you're using:
If you have stateful beans, the container will make sure each client gets the right instance.
If you use stateless beans, these are shared between clients. If you're storing any client-specific state in these, this could easily get shared across sessions.
If you use singletons, you need to make sure that no session-specific state is stored, and that any shared state uses appropriate locks.
It's also worth checking your application logic - if it appears data is being shared across sessions, is it possible it's just the wrong data?
Finally, the big thing you're going to need is appropriate debug logging. You'll need to get enough information about what's going on from the log to identify where the problem is going wrong. Unfortunately these kind of contention issues can be fiddly and hard to catch, especially with a debugger, but appropriate logging will make your life much better in any case.
Of course, this is all quite vague and generic, but without more detail on the system that's inevitable. I would suggest looking for state stored on stateless beans as a first step though!
Trying to get better performance out of my Xpages applications. Reading Mastering Xpages 2Ed, blogs, installed Xpages Toolbox.
One application in particular is very slow. The user sets some configuration documents that the program then loads into sessionScope variables. I use these heavily for setting up the navigation in the app.
Chapter 19 has many useful tips about performance and I am reviewing them. One guides you to rely too heavily on sessionScope variable, but use viewScope or managed beans.
Why are sessionScope variables a drag on performance and what could I use to increase performance?
Also, I am trying to use the Toolbox to profile my app and find out where the bottlenecks are, but I just don't quite get it. Should I use the CPU Profiler or the BackendP Profiler?
Any help would be greatly appreciated.
I don't believe there's any real "performance" difference in the scopes - meaning the speed of pulling the data from the scope.
I used to use sessionScope all the time but now try to avoid it for other reasons. sessionScope is great for a shopping cart for instance but very bad for "application state or page state". I used to use sessionScope for different stuff and then someone would open the same app in a second tab and that would cause problems.
I've not really used the profiler much - but it's HIGH on my list. Personally I'm much more interested in the backend profiler because that should really tell me what's going on with my code - which is probably the easiest to change.
Howard just did a great performance session at the MWLug conference. You might want to find those slides. (Sorry don't have that handy) but I suspect you can find them through his company site: tlcc.com. Also, a while back there was a webinar on performance that you might find interesting. https://www.youtube.com/watch?v=OXXi6cvBxGw
You have to be careful about using sessionScope beans - they will hang around until sessions time out. I have written a little article about this based on my experience. Have a look and see if it explains well enough why - and what the alternatives are (short session timeout and keepalive functionality).
HTH
/John
During the rather larges xPages application development a realized the fact that Domino deletes alls sessionScope, viewScope, applicationScope variables in application after any change in application design(that causes some internal application reload on server). I understand this for development process, but its realy unacceptable in production because it makes inconsistences for connected users. Even simple typo correction in code or on xpage(on any xpage, not the one the user is working on) and applying changes to production application causes this deletes. Is there a way how to overcome this behaviour? (I know I can update application outside of business hours or something but its problem for new application when you need to deliver changes quickly e.g. typo fixes ...)
This has to be done because any changes in your application could cause the scoped variables ( and its contents) to invalidate. Updating an application ( any not only xpage apps ) should be done in a specified trimeframe at which there are none / limited amount of users.
This answer to a previous question might provide an option for you. In the context of the original question, the suggestion for defining listeners was just to provide an opportunity to do some cleanup prior to the scopes being destroyed. These types of listeners, however, could also be used to save and restore the state of these scopes. I'd urge caution for the reasons JJTB mentions, but certainly in situations where you're making completely unrelated changes (e.g. structural, not logical), this would give you a way to prevent users from being impacted by frequent scope clearing.
jjtbsomhorst explained the reason. I want to add: don't rely on scoped variables and use beans. Beans contain "formula for cooking a fresh one" what is much safer for application. Any scoped variable computed on specific event (on load typically) will be lost forever, if you make update to application as mentioned in your question. But if you used bean - its values will be recreated whenever needed again.
This is a very simple question for which i present my apologies but i need expert guidance on it since my knowledge is way too primitive that i don't know what to search on google to solve my problem.
I have developed a simple data entry application in jsf which gives users a form to enter data then generated one pdf report on the basis of data. The application works fine but when more then one user simultaneously tries to enter data, users can't do that, only one user at a time can enter data.
Please give me some idea what should I should study and on what subject I need to do the research.
Thanks in advance.
That can only mean that you're holding some request/session scoped information in static variables or in application scoped variables which would then be shared among all users in the entire application. Apparently you've either awarely or unawarely programmed some static/application wide lock which prevents other users from using the same application.
It's not possible to give a targeted answer as to how to fix this problem as you didn't show any code, but you should start looking at static variables and application scoped variables and investigate if they aren't incorrectly holding request/session scoped data. If they do, then you should make them non-static and/or request/session scoped instead.
I'm working on a JSF 1.2 project which has AJAX functionality on it's pages (using RichFaces).
My bean builds a list of objects to be edited and then has methods to support the editing and the bean is session-scoped. I will be using a a4j:queue so that only one AJAX call can happen at a time.
I'm curious if it is wise to use synchronization (locks on objects, or perhaps collections from java.util.concurrent) in the managed bean. Is the extra work needed to implement synchronization/thread safety really needed? The site I am working on has many users and needs to be reliable but it has a LOT of managed beans, and I'm curious how concerned I should be about the thread safety of managed beans overall.
Do you take extra steps in backing beans for thread-safety?
Thanks in advance.
a4j:queue won't prevent the user from reloading the page / clicking another link while the AJAX call is in progress.
Yes, we can probably trust the user not to click many different links right after each other, but what about requests not triggered by the user, for instance by a4j:poll?
Note that replacing all collections with their thread-safe equivalent might not be enough to make your application thread safe.
That said, depending on the degree of reliability your application needs to meet, this problem might or might not deserve your attention.
You need to keep scope in mind.
Request scope - thread safe, session scope - not thread safe
If you need to be able to open multiple browser windows or tabs, then you can use something like a Seam conversation to protect from editing the same object from two windows/tabs.
If it is SessionScoped you must take care to use some thread-safety mechanisms. If it is RequestScoped or ViewScope'd, then it is safe to share class variables between methods.