I have a FW/1 app on Railo 4.2.2/Apache and for some reason it's calling onApplicationStart
on every request. I can tell it's not any reinit code - put in a callStackGet()
dump in setupApplication
and can see that the root call is onApplicationStart (not via any init hook). Are there any known bugs in Railo that would cause this? I've double checked the application timeout (1 day) and the FW/1 setting - it's turned off - so there should be no reason the app would be losing application scope on every request.
There is another strange thing I'm seeing too, but I don't know that it is related. In setup application I am creating a new user object (via ORM) and persisting it if a local admin doesn't exist. I dump it and see the ID, but it's not in the database when I query the table (yes, I flushed it). The next page hit creates the user again (since it doesn't exist still...).
Edit: Add persist object code for Adam.
function setupApplication() {
// bean factory should look in the model tree for services and beans
var bf = new framework.ioc( "/com/sharp/model" );
setBeanFactory( bf );
ormReload();
if( getEnvironment() == 'dev' ){
writeLog('Checking for dev user');
if( !arrayLen( ormExecuteQuery('from User where username = ?', ['admin']) ) ){
var user = new com.sharp.model.user.User({username: 'admin', password: hash('p@ssw3rd'), isAdmin: true});
entitySave( user );
ormFlush();
writeDump(user);
writeDump(callStackGet());
writeLog('User admin created')
}
else{
var user = bf.getBean('userService').getByUsername('admin');
writeLog('Dev admin user already exists. Done.')
}
var auth = bf.getBean('userService').authenticate( 'admin', 'p@ssw3rd' );
}
}
I think the failure to persist to the DB may be a regression bug with Railo 4.2.2. See https://issues.jboss.org/browse/RAILO-3279
Try wrapping your save/flush in a transaction:
Normally you shouldn't need both. Either the transaction or ormFlush should make it persist.