And*_*lko 5 java tomcat executorservice apache-tomee java-ee-7
我的技术栈包括
为了能够ManagedExecutorService
更明智、更安全地使用和管理线程,我想包含此依赖项
我尝试以不同的方式将 bean 注入到不同范围的 bean(基于视图、会话、基于应用程序)中。
@Inject
private javax.enterprise.concurrent.ManagedExecutorService service;
Run Code Online (Sandbox Code Playgroud)
@Resource
private javax.enterprise.concurrent.ManagedExecutorService service;
Run Code Online (Sandbox Code Playgroud)
@Resource(lookup="java:comp/DefaultManagedExecutorService")
private javax.enterprise.concurrent.ManagedExecutorService service;
Run Code Online (Sandbox Code Playgroud)
似乎没有任何效果,异常消失
Run Code Online (Sandbox Code Playgroud)java.lang.RuntimeException: Error looking up java:comp/env/.../ManagedExecutorService in JNDI javax.naming.NameNotFoundException: Name [.../ManagedExecutorService] is not bound in this Context.
这可能是由于 bean 注册不当造成的。因为我没有找到。我扫描了整个类路径,但在ManagedExecutorService
某处找不到任何定义或其任何实现的东西。
我试图自己注册它,context.xml
但无济于事。我使用这个 TomEE 教程(天真地)假设我的非 EE Tomcat 的配置是相同的。
<Resource name="ManagedExecutorService"
type="javax.enterprise.concurrent.ManagedExecutorService" />
Run Code Online (Sandbox Code Playgroud)
<Resource id="ManagedExecutorService"
type="javax.enterprise.concurrent.ManagedExecutorService" />
Run Code Online (Sandbox Code Playgroud)
显然,事实并非如此。
我的问题是
是否可以在非 EE 服务器上设置并发实用程序,尤其是 Tomcat 8.5?
如果是这样,我在这里错过了什么?
我无法切换到任何 JavaEE 应用程序服务器。
我无法升级列出的依赖项。
有关的:
归档时间: |
|
查看次数: |
486 次 |
最近记录: |