Transaction problems on Windows
Creating a user account fails with a NullPointer exc in UsersImpl.createWorkspace() on line 165, because preferences.getWorkspacePath() returns null
Cause : it triggers Preferences initialization which calls PreferencesManager.verifyPreference() which tries to start & commit a NEW transaction to persist the user workspace preference while there is already a current transaction
Short term solution : init Preferences before starting the first tx, ex. by adding preferences.getWorkspacePath(); before entityManager.getTransaction().begin(); in UsersImpl.createAccount()
Longer term solutions : evaluate interest of alternatives :
- by using the pattern "session in view" i.e. one tx per user web action, by putting an Intent over the main servlet which begins & commits tx HOWEVER COSTLY
- checking first if a tx exists by writing a TransactionHelper { doInTransaction { if !tx.exists() begin(); internalDoInTransaction(); if !tx.exists() commit(); } } and using it by implementing internalDoInTransaction() everywhere a tx is committed now
- adding transaction boundary control by annotating classes & methods, using Spring's or without. HOWEVER this would be a major addition to FraSCAti as an app development platform...