Occasional weird Glassfish errors, resolved by a restart? - jsf

I'm developing a web app using netbeans with GlassFishv3.
Every once in a while when I add a new feature in my app, glassfish starts nagging with stupid errors, after a lot of time wasting and panicking, i restart glassfish and run my application again, then suddenly the errors all go away and my site starts acting correctly. (or in case I have made a real mistake, i receive a reasonable & descriptive error from GF.)
[Edit: the rest of the question was revealed to have been my own mistake.]
But the problems don't end there. Recently, i added the ability to write comments in a (JSF) page, after the user submits their comment, i add it to the database and redirect to the same page, so that hopefully the page refreshes with the new comment, but it wont!
The underlying Mysql database shows that the new comment has been added, but the page just wont show the new comment! I've tried everything (e.g. deleting browser cache, using different browsers) but only after restarting GF is when the page shows the new comment!
Do you have any idea what the problem could be? Could this be a Glassfish bug?
What i am using: JSF2, EJB3.1, JPA, MySql

Apparently the list of comments is not refreshed with new comment. Verify if the data loading logic is right. Maybe you've put it in the constructor of a session scoped bean instead of a request scoped bean. Maybe you haven't reloaded the list from DB after insertion (and commit). Instead of restarting GF, try to restart the webbrowser (close ALL tabs/instances) and reopen the page. If it works, then the old/non-reloaded data has indeed just been displayed from the session scope. If that doesn't solve the problem, then the problem is maybe more in the JPA area, debug if the new comment is actually persisted and committed and/or if the list is actually requested from the DB and not from the cache, etcetera.

thanks for the responses,
Yes, as Balus and Pascal mentioned, the problem lied in my own logic and fortunately not in Glassfish.
Incompetence was on my part, I admit and apologize;)
Indeed the problem was in the JPA area, I had forgotten to merge and refresh my JPA entity after adding the comments; so although the comments were added in the database, my JPA entities wouldn't reflect the changes.
By the way, FYI, I still have the occasional problem of my projects plain not building and/or not deploying into GF (while emitting weird error messages), which is always solved by restarting GF (more specifically, by restarting the default domain in GF);
It could probably be my mistake, or netbeans6.8's deployment bug, or in the unlikely case, GF's fault.

Related

Editing a managed bean for XPINC, rebuild and error 500

Greeting, brethren,
So I inherited this app (yes, XPages can be legacy now ;-). It is meant for the Notes client only and one process takes a convoluted route via what I understand is called a Managed Bean (the Code/Java design element).
The database resides on a server.
When editing said bean.java, I meet two issues.
If I test immediately thereafter, I'm greeted with an Error 500 that won't go away unless I close then restart both Notes and Designer
In some cases, changes made to bean.java are not immediately available. So far I haven't been able to characterize those cases. For example, yesterday afternoon I could no anything, nothing would bring a change to the Notes client. (Yes, I cleaned & rebuilt and autobuild is disabled). This morning changes are apparent immediatly (save for the quit/relauch bore).
I've tried to set xsp.application.forcefullrefresh=true in the app's Xsp properties but haven't noticed much effect.
What am I doing wrong ? What could I do to fluidify the modifying of a bean ?
When working in XPiNC, after every change you have to close and restart designer. If I understand things correctly, it's trying to access class files that have been discarded. That's why whenever I've had to develop for XPiNC, my initial testing during development is on a browser, I would recommend this approach.
There are minimal differences in syntax, usually only encountered if manually creating URLs to files etc or using the bad practice "" to specify database location in #DbLookup. Wherever possible, avoid #Formula approaches, their performance is worse than object orientated methods (e.g. view.getAllEntriesByKey())
It's the same for the bean. There are only two ways to speed up picking up updates - use a browser or use XPiNC on a different PC.

xPages don't work after design update

Load any xPage
Refresh db design
Reload the xPage by either F5 or Ctrl+F5.
then almost all functions stop working without any errors. E.g. nothing happen if you click buttons or menu items. After restarting web browser some functions come back but some still doesn't work. After cleaning browser's cache almost 90% UI start working but some still need to reload the page few times. Is there any xPage app properties or Domino properties to adjust to fix that problem and make xPage app work smooth even after design refresh
Design Refresh didn't reload custom Java classes when refreshing with 8.5.3 FP1. This was fixed, I believe, in FP2. But that doesn't sound like it's causing the problem here.
Design Refresh will not reload jar files. That requires issuing "restart task http" to the console. ("tell http restart" doesn't properly reload everything XPages needs.)
If your application is using a Single Copy XPage Design to hold its XPages design, that too will not update until you issue "restart task http" to the server. The design seems to be cached by the server for better performance, but refreshing the design of the SCXD database doesn't reload that design. It's unclear if that's your scenario here.
XPiNC may also not update immediately, but I've not tried that. The runtime there is basically in the Notes Client itself, so I could understand that it would not update.
Otherwise, I would echo Thomas's experience, I've not seen any other issues (and my applications heavily use Java). I haven't needed to clean the application following a design refresh. Existing browser sessions will have problems with partial refresh calls, I would expect that. But a refresh of the page make all functionality work.
There are two scenarios I would expect to have problems.
The first is if you are storing anything in sessionScope or applicationScope variables that are required by your application, but your code only loads those on a specific page. If you refresh the design, the scopes will get dumped and so not reloaded until you go to the specific page. Typically I put such initialisation code on my layout custom control, so a page reload will always initialise it if it's dumped by a design refresh.
The second is if another user accesses the application and has Build Automatically switched on, which could result in the application being rebuilt without you realising it. It doesn't sound like this is happening for you though.

Java Bean not getting loaded

I have a xpage which uses a java bean to generate some content on the page. The page gives error "Error 500 HTTP Web Server: Command Not Handled Exception". But error just disappears once I open the database using designer. I do not do any modifications to the database, but just open the database using designer client. I have to open the database every day to fix this problem. Can anybody tell me why this is happening and how can I fix it?
"Error 500" is a pretty catch-all error description, and I believe it shows up if you don't tell the app to display the XPages runtime error page (the default with the stack trace) or provide your own. If you do one of those (or look at the server console and error-log-0.xml in the data/domino/workspace/logs folder), you may be able to get a more-specific description of the problem.
But one plausible "crops up every day" type of problem I've run into is the "X is incompatible with X" ClassCastException problem - at some point in the growth of most XPages apps, this starts to crop up (I don't know why other than "using Java") and gets to the point where even changing non-XPage design and potentially data docs triggers it. Fortunately, the fix is easy: assuming you're running 8.5.3 or above, go into the xsp.properties and check the option to "Refresh entire application on design change" (or thereabouts). That should fix it if this is indeed your problem.
Looks like it was my designer client. I was using 8.5.3 without any fix packs. I installed FP6 and signed the design again and the problem is fixed.

The entity's form doesn't get updated

I have a HTML file, which I've uploaded as a web resource and linked to via an activity's form designer in an IFRAME. So far, so good.
Then, when I edited the source file locally and uploaded it (browse-save-publish, of course), I got no difference in the appearance on the screen. Here's the weird part. When I open the uploaded file in the editor, I can see the changes to my source code. On the RTF tab I can also see the change in colors of the background.
However, reloading the "create new"-form doesn't bring those changes to the client! I've tried restarting the window, restarting IE, clearing the cache. Nothing helps.
When I entered the very same page from a different client, I got to see the updated version. But after that, the subsequent changes are not updated either. It's like if IE thinks "oh, matey, ya wanna cache that for life, I see". Well, I don't. I'd like to see my edition in action pretty much directly and without creating a new account with a new client. :)
After a while, the update seems to go through and I get to see a new version but not in all browsers.
What is causing it?! How do I kill it?
(Win8/IE10/CRM11OL)
I have seen CRM do some weird IIS Caching. I'd assume this is a server side issue, but your using crm online, they won't let you run an IIS reset now will they? :) Have you tried running it on a new client in private browsing mode, deploying your change, and opening a new private browser to test if it is a client caching issue or a server caching issue?

Single user for whole application?

In my application, JSF2.0, richfaces 3.3.3 and Tomcat.
I need, to prevent user multiple tabs in same browser.
Means, If the user login into the application, after that copying the url and paste into the other tab..that time i need to logout that user..
Help me...
Thanks inadvance.
You can and should not. You can not, because it can never be achieved reliably. JavaScript can do a lot, but you're still dependent on whether the enduser has it enabled and or the browser can successfully fire a (XML)HTTP request before the unload event, which is really a race condition. You should not, because it would completely destroy the user experience and only result in "wtf?" experiences.
You need to fix the real underlying problem for which you thought that this would be the right solution. This smells too much like session scope abuse. In that case, take your time to go through How to choose the right bean scope? You seem to really need the view scope instead.

Resources