FW / 1应用程序调用onApplication开始每个请求 [英] FW/1 App Calling onApplicationStart on Every Request

查看:183
本文介绍了FW / 1应用程序调用onApplication开始每个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Railo 4.2.2 / Apache有一个FW / 1应用程序,并且由于某种原因它在每个请求调用onApplicationStart。我可以告诉它不是任何reinit代码 - 在setupApplication中的callStackGet()转储,可以看到根调用是onApplicationStart(不通过任何init钩子)。在Railo有没有任何已知的错误,将导致这一点?我已经双重检查应用程序超时(1天)和FW / 1设置 - 它已关闭 - 所以应该没有理由应用程序将丢失每个请求的应用程序范围。

I've got 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.

我还看到另一个奇怪的事情,但我不知道它是相关的。在设置应用程序中,我创建一个新的用户对象(通过ORM),如果本地管理员不存在,持久化它。我转储它并查看ID,但它不在数据库中,当我查询表(是的,我刷新它)。下一页命中再次创建用户(因为它不存在...)。

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...).

编辑:为Adam添加持久性对象代码。

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

}


推荐答案

我认为无法坚持到DB可能是一个回归错误与Railo 4.2.2。请参见 https://issues.jboss.org/browse/RAILO-3279

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:

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

通常,您不应同时需要两者。要么事务或ormFlush应该使它持久。

Normally you shouldn't need both. Either the transaction or ormFlush should make it persist.

这篇关于FW / 1应用程序调用onApplication开始每个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆