views:

88

answers:

2

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

A: 

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.

BalusC
A: 

Hello everyone, 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.

Pooria