在Weld / Seam3应用程序上启动POJO [英] Startup POJO On A Weld/Seam3 Application

查看:115
本文介绍了在Weld / Seam3应用程序上启动POJO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的Weld / Seam3应用程序中启动时启动POJO但没有太多运气。我尝试了以下但没有一个有效:

I'm trying to get a POJO starting on startup within my Weld/Seam3 application but not having much luck. I've tried the following but none of them have worked:

@Singleton
public class StartupJobs {
    @Inject
    private Logger log;

    public void onStartup(@Observes @Initialized ServletContextEvent event) {
        log.info("Starting startup jobs");
    }

    public void onStartupTwo(@Observes @Initialized WebApplication webApplication) {
        log.info("Starting startup jobs");
    }
}

-

// Guessing this way is no good as I can't use the javax.ejb.Startup annotation here
@ApplicationScoped
public class StartupJobs {
    @Inject
    private Logger log;

    @PostConstruct
    public void onStartup() {
        log.info("Starting startup jobs");
    }
}

但这两种方式都不起作用。我的日志消息从未提出过。由于这个应用程序是在Tomcat6上运行的,我必须将org.jboss.weld.environment.servlet.Listener监听器添加到我的web.xml中,我想知道是否有类似于我可以观察到的类。我没有注意到任何特别的事情。

But neither of those ways worked. My log message was never raised. As this application is run on Tomcat6 and I've had to add the "org.jboss.weld.environment.servlet.Listener" listener to my web.xml, I'm wondering if there's something that class raises that I could observe. I didn't notice anything in particular though.

有什么线索可以尝试吗?

Any clue what else I could try?

推荐答案

发现我的问题是配置。由于在Tomcat 6上,我没有看到我需要一些额外的配置: http://docs.jboss.org/seam/3/servlet/latest/reference/en-US/html/servlet-installation.html# installation.pre-servlet-3

Found out my issue was configuration. I hadn't seen I needed some extra configuration due to being on Tomcat 6: http://docs.jboss.org/seam/3/servlet/latest/reference/en-US/html/servlet-installation.html#installation.pre-servlet-3

关于该页面上的文档的快速说明,就像我写的那样,Catch Exception的类过滤应该是org.jboss.seam.servlet.exception.CatchExceptionFilter。文档缺少例外。它似乎已在Seam Servlet代码中得到修复,因此我想这个错误将在下次发布文档时修复。

A quick note on the documentation on that page as it stands as I write this, the class for the "Catch Exception Filter" should be "org.jboss.seam.servlet.exception.CatchExceptionFilter". The documentation is missing out the "exception". It seems to have been fixed in the Seam Servlet code so I imagine this bug will be fixed next time the documentation is released.

这篇关于在Weld / Seam3应用程序上启动POJO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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