Seam-Persistence & Glassfish - sometime cannot write to database
baraber May 5, 2011 11:33 AMHello guys, this one caused me a lot of headache
I use Glassfish 3.1(b-43) with seam-persistence (3.0.0.Final). Replaced weld osgi bundle in glassfish to version 1.1.1.Final.
Sometimes the application cannot issue insert statements in the database. By this I mean I activated the query logs and I see all read queries but not write queries. But the problem is inconstant. Some time when I start the application all works fine. Some other times write queries aren't processed.
When the problem happens, I just restart the application and have a chance it will work. If not, restart again, and again... When it works, it seems to keep working until I restart.
I can have no problem at all across multiple restarts as I may have to restart it multiple time before all works fine.
I first noted the problem on a personal application. Being unable to find any information on a similar problem, I had to remove seam-persistence from my project to use an ejb with @PersistenceContext and the problem seemed to be gone completely.
But not I have to use seam-security, who itself uses seam-persistence. And again I face the problem.
One can test it with the seam-security idmconsole example.
To test, juste start idmconsole in glassfish, log in(demo/demo), and try to create a new user. Sometime all is ok, but other times, I cannot create the user :
Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities. ... at org.jboss.seam.security.management.picketlink.JpaIdentityStore.lookupIdentity(JpaIdentityStore.java:1233) at org.jboss.seam.security.management.picketlink.JpaIdentityStore.updateCredential(JpaIdentityStore.java:1803) at org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository.updateCredential(WrapperIdentityStoreRepository.java:310) at org.picketlink.idm.impl.api.session.managers.AttributesManagerImpl.updatePassword(AttributesManagerImpl.java:563) at org.jboss.seam.security.management.action.UserAction.saveNewUser(UserAction.java:156) at org.jboss.seam.security.management.action.UserAction.save(UserAction.java:133) ...
The following line throw the exception
(org.jboss.seam.security.management.picketlink.JpaIdentityStore.lookupIdentity(JpaIdentityStore.java:1233))):
return em.createQuery(criteria).getSingleResult();
This is because of org.jboss.seam.security.management.action.UserAction.saveNewUser(UserAction.java:155, 156) :
User user = identitySession.getPersistenceManager().createUser(username); identitySession.getAttributesManager().updatePassword(user, password);
The call to createUser should have inserted in database so that the call to updatePassword could look the user up and then update its password.
I tried it with hibernate and eclipseLink : same problem.
Tried with XADatasource and non XA datasource : same problem.
Tried with java db(come with glassfish) and with MySQL : same problem.
Can someone help with this, or had similar issue ? Or is anyone using seam-persistence with glassfish without any trouble ?
We never stumble across this problem with JBOSS as.