无法注入TimerService

无法注入TimerService,timer,jboss,ejb,Timer,Jboss,Ejb,我在JBossAS 7.1.1中有一个应用程序,希望使用TimerService。我这样说: @Resource private TimerService timerService; 访问应用程序中的页面时,这会导致以下错误: 16:08:30,471 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/c3e].[Faces Servlet]] (http--127.0.0.1-8080-2)

我在JBossAS 7.1.1中有一个应用程序,希望使用TimerService。我这样说:

@Resource
private TimerService timerService;
访问应用程序中的页面时,这会导致以下错误:

16:08:30,471 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/c3e].[Faces Servlet]] (http--127.0.0.1-8080-2) Servlet.service() for servlet Faces Servlet threw exception: javax.naming.NameNotFoundException: env/myapp.mypackage.MyClass/timerService -- service jboss.naming.context.java.module.myapp.myapp.env."com.dpdhl.cac.c3e.etl.beans.Resources".timerService
我尝试了其他几种方法,包括注入SessionContext或在InitialContext上使用lookup()来获取SessionContext,但它们都遇到了本质上相同的问题


这里我遗漏了什么?

问题解决了:我向其中注入TimerService的bean必须是EJB,而不仅仅是CDIBean。我补充说

@Singleton

根据bean的声明,它现在可以工作了。

您正在部署什么样的应用程序?(ear/war)TimerService的完全限定类名是什么?