简体   繁体   English

Java EE @Resource没有映射到web.xml

[英]Java EE @Resource isn't mapping to web.xml

I am trying to develop a web application with a java back end but I need to track if the tasks are complete and I am using the ManagedExecutorService for this. 我正在尝试使用Java后端开发Web应用程序,但是我需要跟踪任务是否完成,并且为此使用了ManagedExecutorService

I am trying to use the @Resource annotation to inject a ManagedExecutorService as follows. 我正在尝试使用@Resource批注按如下方式注入ManagedExecutorService

@Resource(name = "myExecutionService")
private ManagedExecutorService mExecutionService;

web.xml: web.xml中:

<resource-env-ref>
    <resource-env-ref-name>myExecutionService</resource-env-ref-name>
    <resource-env-ref-type>javax.enterprise.concurrent.ManagedExecutorService</resource-env-ref-type>
</resource-env-ref>

but I keep getting an error saying that I am missing the "Services with missing/unavailable dependencies" 但是我总是收到一条错误消息,说我缺少“缺少依赖项/不可用依赖项的服务”

13:52:31,207 INFO  [org.jboss.as.server] (management-handler-threads - 158) JBAS015870: Deploy of deployment "tbm-core-1.0.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"tbm-core-1.0.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"tbm-core-1.0.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [TestBedManager] with qualifiers [@Default] at injection point [[field] @Inject private com.shenick.teravm.core.ws.TestBedManagerWebService.testBedManager]"},"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.\"tbm-core-1.0\".\"tbm-core-1.0\".env.myExecutionServicejboss.naming.context.java.jboss.resources.myExecutionServiceMissing[jboss.naming.context.java.module.\"tbm-core-1.0\".\"tbm-core-1.0\".env.myExecutionServicejboss.naming.context.java.jboss.resources.myExecutionService]"]}

I have figured out the problem and it's because ManagedexecutorService is java 7 only apparently and jboss 7.1.1 will not deploy apps that use threads. 我已经解决了这个问题,这是因为ManagedexecutorService显然仅是Java 7,而jboss 7.1.1不会部署使用线程的应用程序。

to solve this I will need to upgrade to EAP 6.1 (new name for jboss). 为了解决这个问题,我将需要升级到EAP 6.1(jboss的新名称)。

If you want just use the default implementation, use 如果只想使用默认实现,请使用

@Resource(mappedName="java:comp/DefaultManagedExecutorService")

In this case, you don't need to specify it in web.xml. 在这种情况下,您无需在web.xml中指定它。

If you want to use your own implementation, I think you should configure your application server resources first (set it with your implementation). 如果要使用自己的实现,我认为您应该首先配置应用程序服务器资源(在实现中进行设置)。

EDIT: 编辑:

I found this by chance: How to Configure Scheduled Tasks in Wildfly . 我偶然发现了这一点: 如何在Wildfly中配置计划任务 It could help you, I think. 我认为这可以为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM