FW / 1 application calling onApplicationStart on each request

I have an FW / 1 application on Railo 4.2.2 / Apache and for some reason it calls onApplicationStartfor every request. I can say that this is not some kind of reinitialization code - add a dump callStackGet()to setupApplicationand see that the root call is onApplicationStart (not through any initialization hook). Are there any known errors in Railo that can cause this? I double-checked the application timeout (1 day) and the FW / 1 setting - it is disabled - so there should be no reason why the application will lose the application area for each request.

There is another strange thing that I also see, but I do not know what this is connected. In the setup application, I create a new user object (via ORM) and save it if the local administrator does not exist. I unload it and see the ID, but it is not in the database when I query the table (yes, I blushed it). The following snapshot of the page creates the user again (since he does not exist yet ...).

Edit: Add 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' );
    }

}
+2
source share
1 answer

I think that the inability to stay in the database may be a regression error with Railo 4.2.2. See https://issues.jboss.org/browse/RAILO-3279

Try wrapping save / write off in a transaction:

transaction{
    entitySave( user );
    ormFlush();
}

. , ormFlush .

0

All Articles